how to identify a user throughtout the site--- by

Results 1 to 4 of 4

Thread: how to identify a user throughtout the site--- by

  1. #1
    baagi Guest

    Default how to identify a user throughtout the site--- by

    hi, how can a user be tracked thruoghout the site... by his username or by his userid from the database.. using session variables.. pl tell me.

  2. #2
    sumedh Guest

    Default RE: how to identify a user throughtout the site---

    u can set a cookie which stores his/her userId and then access this cookie from any page whenever u wish to perform some calculation based on the userId<BR><BR>To set the cookie:<BR> Response.Cookies("&#060;cookie name&#062;")=&#060;value&#062;<BR><BR>To retrieve the contents of a cookie:<BR> Request.Cookies("&#060;cookie name&#062;")<BR><BR>In ur case u can use, Response.Cookies("CurrUserId")=UserId<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: how to identify a user throughtout the site---

    I use cookies and Application variables for my families website so we know who is on the site<BR><BR>the first fill out a user form with their name and email address that intern adds their information to a database and writes a cookie to their computer.<BR><BR>Then I have 2 application variables Application("NotLoggedOn")<BR>this just keeps a list of user inormation of all users in the database and Application("ActiveUsers")<BR><BR>with the global.asa file I add the new user to the application arrays<BR>&#060;SCRIPT LANGUAGE=VBScript RUNAT=Server&#062;<BR><BR>Sub Session_OnStart<BR>Session.Timeout = 20<BR>Session("Start") = Now<BR><BR>If Len(Application("NotLoggedOn")) = 0 Then<BR> Dim Conn<BR> Dim ConnStr<BR> Dim RS<BR> Dim Sql<BR> <BR> Set Conn=Server.CreateObject("ADODB.Connection")<BR> Set RS=Server.CreateObject("ADODB.recordset")<BR><BR> connStr = "DRIVER={Microsoft Access Driver (*.mdb)}; hefamilydirectorycgi-binNotLoggedOn.mdb"<BR> Conn.Open connStr<BR><BR> RS.Open "UserList", Conn, 3, 3<BR><BR> Do While Not RS.EOF<BR> If Len(Application("NotLoggedOn")) = 0 Then<BR> Application.Lock<BR> Application("NotLoggedOn")= RS("Name") & "-" & RS("Email")<BR> Application.UnLock<BR> Else<BR> Application.Lock<BR> Application("NotLoggedOn")= Application("NotLoggedOn") & "," & RS("Name") & "-" & RS("Email")<BR> Application.UnLock<BR> End If<BR><BR> RS.MoveNext<BR> Loop<BR> RS.Close<BR> Conn.Close<BR> Set RS=Nothing<BR> Set Conn=Nothing<BR>End If <BR><BR>Application.lock<BR> Application("visits") = Application("visits") + 1<BR> intTotal_visitors = Application("visits")<BR>Application.unlock<BR><BR >Session("VisitorID") = intTotal_visitors<BR><BR>Application.lock<BR> i = Application("Active")<BR> Application("Active") = i + 1<BR>Application.unlock<BR><BR>&#039;///////////////////////////////////////////////////////<BR>&#039;// Save User logon name to application(Active_Users) //<BR>&#039;///////////////////////////////////////////////////////<BR>If Len(Request.Cookies("Active_Users")("Name")) &#062; 0 Then <BR> If Instr(Application("Active_Users"),Request.Cookies( "Active_Users")("Name")) = 0 Then<BR> If Len(Application("Active_Users")) = 0 Then <BR> Application("Active_Users") = Request.Cookies("Active_Users")("Name")& "-" & Request.Cookies("Active_Users")("Email") & "-" & Session.SessionID<BR> Else<BR> Application("Active_Users") = Application("Active_Users") & "," & Request.Cookies("Active_Users")("Name") & "-" & Request.Cookies("Active_Users")("Email") & "-" & Session.SessionID<BR> End If<BR> End If<BR>End If<BR>&#039;///////////////////////<BR>&#039;// End Save Function //<BR>&#039;///////////////////////<BR>End Sub<BR><BR>Sub Session_OnEnd<BR><BR>Application.lock<BR>i = Application("Active")<BR>Application("Active") = i - 1<BR><BR>&#039;///////////////////////////////////////////////////////////<BR>&#039;// Remove User logon name from application(Active_Users) //<BR>&#039;///////////////////////////////////////////////////////////<BR>A_users= Split(Application("Active_Users"),",")<BR><BR>for a = 0 to Ubound(A_users)<BR> If Instr(Application("Active_Users"),Session.SessionI D) = 0 Then<BR> If Len(Tmp_Users) = 0 Then<BR> Tmp_Users = A_users(a)<BR> Else<BR> Tmp_Users = Tmp_Users & "," & A_users(a)<BR> End If<BR> End If<BR>next <BR>Application("Active_Users") = Tmp_Users<BR>&#039;/////////////////////////<BR>&#039;// End Remove function //<BR>&#039;/////////////////////////<BR>Application.unlock<BR><BR>End Sub<BR><BR>&#060;/SCRIPT&#062;<BR>I add the users sessionID so that I can remove them from the active_users array when their session times out.<BR><BR>I have the notloggedon list because I use a dropdown list to show whether the user is logged on or not, thats not really needed except that I have a message center for people to leave messages for other family members whether they are on the site or not<BR><BR>Hope this helps

  4. #4
    Join Date
    Dec 1969

    Default RE: how to identify a user throughtout the site---

    Use a cookie, or yeah.. even a session variable array.<BR><BR>Learn how to use them here:<BR><BR><BR>Vadim C.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts