Can't persist the cookie

J

JimFoye

ticket is an instance of FormsAuthenticationTicket;

HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName,
FormsAuthentication.Encrypt(ticket));

if (ticket.IsPersistent)
cookie.Expires = DateTime.Now.AddYears(1);

Response.Cookies.Add(cookie);

I added the 2 lines to set cookie expiration after seeing that in an article
written by an MS employee. Alas, it doesn't help.

Any ideas?
 
J

JimFoye

That doesn't help. Why would setting the expiration back a year help? But I
appreciate the response.

The authentication API seems very confused. Why is a ticket persistent?
Isn't the cookie persistent? Would I want to persist the cookie and not the
ticket, or vice versa? And why do the published code samples NOT WORK?
 
J

Jim Foye

Here's another example of API confusion. I can add a cookie, or I can set a
cookie. Hmmmm.....that's clear as mud, isn't it? What does it mean to call
set on a collection? But there it is

Context.Response.Cookies.Set(cookie);

I defy anyone to tell me that's logical.
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top