How can I add my own data to a Web.FormsAuthentication cookie?

R

Rof

I am using FormsAuthentication.RedirectFromLoginPage(...) to give my
users a cookie, but I want to include other bits in the cookie, like
their name, what they are asking for, and so on. I have this in
Login.aspx:

System.Web.Security.FormsAuthentication.RedirectFromLoginPage("Peter",
True)
Response.Cookies("Peter").Expires = Now.AddSeconds(60)
Response.Cookies("Peter")("whoami") = "Anon"

In the form it redirects to, I can only access
'Request.cookies("Peter")("whoami")' until the cookie expires - which
is logical. However, I still get sent straight there (no Login.aspx)
after the 60 seconds have expired. Does thes mean I have 2 different
cookies? If so, how can I get "whoami" and the expiry time into the
correct, FormsAuthentication cookie?

If the last 2 lines of code are these:

Response.Cookies(0).Expires = Now.AddSeconds(60)
Response.Cookies(0).Values.Add("whoami", "Anon")

Then it won't authenticate me at all, but keeps re-displaying
Login.aspx.

Help!
Peter Royle
 

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,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top