Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm trying to retrieve the currently logged in user and put it into a cookie on the client's machine. However when I try this all I end up getting is the server's "generic" account. I'm obviously doing something wrong so hoepfully someone can point me in the right direction. Here is my code:

 

If Request.Browser.Cookies Then
           If Request.Cookies("LastVisit") Is Nothing Then
               Dim cookLastVisit As New HttpCookie("LastVisit", Now.ToString)
               cookLastvisit("UserName") = System.Environment.UserName
               cookLastVisit.Expires = DateTime.Now.AddDays(1)
               Response.Cookies.Add(cookLastVisit)
           Else
               Dim cookLastVisit As HttpCookie = Request.Cookies("LastVisit")
               Response.Cookies("LastVisit").Value = Now.ToString
               Response.Cookies("LastVisti").Expires = DateTime.Now.AddDays(1)
           End If
       Else
           Response.Write("Your browser does not accept cookies")
       End If

Posted

pruebens:

I may be wrong here (stranger things have happened), but perhaps if you try "Page.User.Identity.Name.ToString" to grab the login of the user currently logged in. My boss mentioned that to my team and I once and I believe that is what it is for. Hope this is right and it helps! :cool:

3,450,897,223 posts away from crazy...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...