FormsAuthentication ticket persistence

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

At the end of my login process I am generating my own Persistent
FormsAuthentication ticket.
I encode this and set a cookie value. I then use
Response.Cookies.Add(cookie), and
I continue the login process. The cookie is not persisted across sessions
and does not appear in the cookie list on the client.
If I use SetAuthCookie persistence works. What am I missing here, in not
getting the desired effect with my own ticket?
 
Dim ticket As FormsAuthenticationTicket = New
FormsAuthenticationTicket(1, _
EmpID.ToString, _
DateTime.Now, _
DateTime.Now.AddHours(12), _
chkRememberLogin.Checked, _
Roles)

Dim cookie As HttpCookie = New
HttpCookie(FormsAuthentication.FormsCookieName)
cookie.Value = FormsAuthentication.Encrypt(ticket)

If (chkRememberLogin.Checked) Then cookie.Expires =
ticket.Expiration ' do you have this line???

HTH,
Greg
 
Greg Burns said:
Dim ticket As FormsAuthenticationTicket = New
FormsAuthenticationTicket(1, _
EmpID.ToString, _
DateTime.Now, _
DateTime.Now.AddHours(12), _
chkRememberLogin.Checked, _
Roles)

Dim cookie As HttpCookie = New
HttpCookie(FormsAuthentication.FormsCookieName)
cookie.Value = FormsAuthentication.Encrypt(ticket)

If (chkRememberLogin.Checked) Then cookie.Expires =
ticket.Expiration ' do you have this line???

HTH,
Greg





cookie.expires is key. thanks greg. Of course the ticket expiration is subject to change depending on the session durations , so the cookie life has to be made sufficiently large or adjusted.

Thanks again
 
Back
Top