I wrote this code,
seems to work fine when the browser is open, but once the session ends or the browser closes, the cookie deletes itself.
I''m sure it's something really simple but I don't know what it is.
Any help would be greatly appreciated
seems to work fine when the browser is open, but once the session ends or the browser closes, the cookie deletes itself.
I''m sure it's something really simple but I don't know what it is.
Any help would be greatly appreciated
Code:
For the Remember me field
If Cookie = True Then
Dim MembersCookie As New HttpCookie(CookieSiteName)
'Context.Response.Cookies.Remove(CookieSiteName)
'MembersCookie.Values.Add("Login", Username)
'encrypts cookie data
SecureCookie.SetCookie(Context.Response, "Login", Username)
'encrypts cookie data
'MembersCookie.Values.Add("Pass", Password)
SecureCookie.SetCookie(Context.Response, "Pass", Password)
MembersCookie.Values.Add("AutoLogin", "On")
' MembersCookie.Domain = "www.ReefJunkies.Org"
Dim dtExpiry = DateTime.Now.AddDays(15) 'you can add years and months too here
Context.Response.Cookies(CookieSiteName).Expires = dtExpiry
Context.Response.Cookies.Add(MembersCookie)
ElseIf Cookie = False Then
'Change autologin in cookie to off
Dim cookie As HttpCookie = Context.Request.Cookies.Get("ReefJunkies")
cookie.Values.Add("AutoLogin", "Off")
Context.Response.Cookies.Add(cookie)
'Context.Response.Cookies.Remove(CookieSiteName)
End If
For the logout
'Change autologin in cookie to off
Dim cookie As HttpCookie = Request.Cookies.Get("ReefJunkies")
cookie.Values.Add("AutoLogin", "Off")
Response.Cookies.Add(cookie)
Response.Redirect(Application("LogOutPage"))