Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a cookie "IMF" which has the UserID set and the expiration is "End of browsing session".
I created a second cookie "LoginTime" and this cookie updates everytime the user changes pages.
I set the LoginTime cookie expiration after 2min and assigned it to a variable. I want to use this
variable to update the expiration of the IMF cookie.
When I check the browsing session cookies, IMF cookie is successfully updated with the
expiration after 2 mins, but "Response.Cookies("IMF").Expires = ExpireTime" the same statement is directly taking me to the "not logged in" page.
I was expecting to login first and then logout after 2 mins.
Where am I going wrong? Please help

VB


VB
Public Sub CheckLogin()

       If Not Request.Cookies("LoginTime") Is Nothing Then
           Response.Cookies.Set(New HttpCookie("LoginTime", Now()))
       End If

       Response.Cookies("LoginTime").Expires = DateTime.Now.AddMinutes(2)
       Dim ExpireTime As DateTime = DateTime.Now.AddMinutes(2)

       Response.Cookies("IMF").Expires = ExpireTime


       Dim strUser As String = ""

       If Not IsNothing(Context.Request.Cookies("IMF")) Then
           'IMF Cookie has a value. See if it's a ED cookie
           If Not IsNothing(Context.Request.Cookies("IMF")("EDUserID")) Then
               strEDUser = Request.Cookies("IMF")("EDUserID")


           End If
       End If

       'If this value is NULL, the the user is not a ED user. Send them to login page
       If strUser = "" Then

           Response.Redirect("not.logged.in.aspx")
       End If
   End Sub
Posted
Comments
Palash Mondal_ 4-Sep-15 9:16am    
Are you updating Dim strUser value anywhere? As per the CheckLogin() code it seems to be always a empty string?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900