See if a website user is logged in and read the cookie

(Guy Forssman) #1

Hi There,

A website uses a cookie to store the id of a user and if he/she is logged in or not.

The code from the website itself is below.

I wish to check if a user is logged in or not and uses this

_paq.push([‘setCustomVariable’,‘1’,‘VisitorType’,’<?php if (!empty($_cookie{customersession}) {echo "Member";} else {echo "Not Member";} ?>’, ‘visit’]);

However I must be doing something wrong as it isn’t working.
Can somebody point me to my fault.

Best regards

Protected Sub Page_Load1(sender As Object, e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
If Debugged.Cookie.CustomerSession.IsLoggedIn Then
End If
End If
End Sub

''' <summary>
''' Load Customer Data
''' </summary>
''' <remarks></remarks>
Protected Sub LoadCustomerData()
    Dim customer As New Debugged.BLL.Customer
    CurrentCustomer = customer.GetObjectByUid(Debugged.Cookie.CustomerSession.CustomerUid)
    For Each row As DataRow In CurrentCustomer
        txtLastname.Text = Debugged.Cast.String.ObjectToString(row.Item("lastname"))
        txtFirstname.Text = Debugged.Cast.String.ObjectToString(row.Item("firstname"))
        txtStreet.Text = Debugged.Cast.String.ObjectToString(row.Item("street"))
        txtNumber.Text = Debugged.Cast.String.ObjectToString(row.Item("number"))
        txtPostalcode.Text = Debugged.Cast.String.ObjectToString(row.Item("postalcode"))
        txtCity.Text = Debugged.Cast.String.ObjectToString(row.Item("city"))
        ddlCountry.SelectedValue = row.Item("country_id")
        txtEmail.Text = Debugged.Cast.String.ObjectToString(row.Item("email"))
        txtTelephone.Text = Debugged.Cast.String.ObjectToString(row.Item("telephone"))
        CurrentCustomerPassword = Debugged.Cast.String.ObjectToString(row.Item("password"))
End Sub

(Guy Forssman) #2

if (!member) {member = “Niet Ingelogged”;} {member}
console.log("Member ",member);

_paq.push([‘setCustomVariable’,1, “VisitorType”, member, “visit”]);