newbie question on forms auth with custom data

  • Thread starter Thread starter Keith
  • Start date Start date
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?
 
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
 
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?
 
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
 
Back
Top