newbie question on forms auth with custom data

K

Keith

I have a simple app that uses "simple" forms auth and works quite
nicely. Now all I want to add is the ability to store a handful of
custom data in the auth ticket and am very confused about how to do so.
I tried sticking it in a session variable (I come from old asp) but of
course the session and tickets don't expire at the same time...argh.

I am authenticating the user against my a mySQL database using:
---
FormsAuthentication.SetAuthCookie(txtUserName.Text, True)
and
FormsAuthentication.SignOut()
---
It works great, but the docs I have read talk about using global.asax
and the prinicpal and encrypt/decrypting cookies and my head starts to
get fuzzy.

Can someone supply some sample code to store (and then retrieve) some
custom data from the auth ticket?
 
T

Tim Mackey

hi keith,
sounds like a simple cookie may be the easiest option?
obviously it isn't integrated with the sign-in process, but it may solve the
problem.

tim
 
K

Keith

Tim,
Thanks for the reply. This custom data is valid only for the "logged
in user", and so it must expire when the ticket does - so I was
thinking they needed to be together. Does that make sense or am I
just not getting it?
 
T

Tim Mackey

hi keith,
i was thinking you could set the cookie expiration to your session timeout
value, to maintain consistency. you could add code to your logout routine
to remove the cookie. it isn't "integrated" like the approach in the docs,
but if that way was causing neural overload then it would be an option at
least.
tim
 

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,777
Messages
2,569,604
Members
45,227
Latest member
Daniella65

Latest Threads

Top