FormsAuthentication ticket persistence

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?
 
G

Greg Burns

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top