Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Forms Authenication Cookie Not Expiring Correctly

Reply
Thread Tools

Forms Authenication Cookie Not Expiring Correctly

 
 
=?Utf-8?B?TWlrZQ==?=
Guest
Posts: n/a
 
      06-07-2004
I have a web application that the forms authentication cookie is not expiring correctly. When I look at the trace information of a newly requested page after the session and forms authentication have expired the forms authentication cookie is assigned a new value. I am never redirected to the login page after my initial login. If I access the site from http://localhost/myapp instead of myapp.domain.com the cookies expire correctly. The cookie are be sent/recieved by the client as I'm able to store data in the session and I can get past the login page. Any Ideas???
 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWlrZQ==?=
Guest
Posts: n/a
 
      06-07-2004

I have tracked it down to the code in the global.asax. If i comment out the Application_AuthenticateRequest code the user is redirected to the login page after the authentication ticket has expired. I don't know why the cookie is in the Request object as it should have expired and never sent to the server. Is this a bug in MS's example or in the way that the expiration time is set on the cookie or in the fact that the cookie is being sent to the server??? Thanks

Mik

protected void Application_AuthenticateRequest(Object sender, EventArgs e

//extract the forms authentication cooki
string cookieName = FormsAuthentication.FormsCookieName
HttpCookie authCookie = Context.Request.Cookies[cookieName]

if (null == authCookie

//there is no authentication cooki
return


//extract and decrypt the authentication ticket from the forms authentication cooki
FormsAuthenticationTicket authTicket = null
try

authTicket = FormsAuthentication.Decrypt(authCookie.Value)

catch//(Exception ex

return


if (null == authTicket

//cookie failed to decry
return

else if (authTicket.Expired

return


//parse out the pipe separate list of role names attached to the ticket whe
//the user was originally authenticate
//when the ticket was created, the UserData property was assigned
//pipe delimited string of role name
string[] roles = authTicket.UserData.Split(new char[] {'|'})

//create a FormsIdentity object with the user name obtained from the ticket nam
//and a GenericPrincipal object that contains this identity together with the user's role lis

//create an Identity objec
FormsIdentity id = new FormsIdentity(authTicket)

//this principal will flow throughout the reques
GenericPrincipal principal = new GenericPrincipal(id, roles)

//attach the new principal object to the current HttpContext objec
Context.User = principal


----- Mike wrote: ----

I have a web application that the forms authentication cookie is not expiring correctly. When I look at the trace information of a newly requested page after the session and forms authentication have expired the forms authentication cookie is assigned a new value. I am never redirected to the login page after my initial login. If I access the site from http://localhost/myapp instead of myapp.domain.com the cookies expire correctly. The cookie are be sent/recieved by the client as I'm able to store data in the session and I can get past the login page. Any Ideas???
 
Reply With Quote
 
 
 
 
John Saunders
Guest
Posts: n/a
 
      06-07-2004
"Mike" <> wrote in message
news:1E1979C5-DDF8-4A8C-A137-...
>
> I have tracked it down to the code in the global.asax. If i comment

out the Application_AuthenticateRequest code the user is redirected to the
login page after the authentication ticket has expired. I don't know why the
cookie is in the Request object as it should have expired and never sent to
the server. Is this a bug in MS's example or in the way that the expiration
time is set on the cookie or in the fact that the cookie is being sent to
the server??? Thanks!

Check on the domain being assigned to the cookie. If you get different
results based on the URL, it's probably a domain problem (though there's a
small chance it could be a path problem).
--
John Saunders
johnwsaundersiii at hotmail


 
Reply With Quote
 
=?Utf-8?B?TWlrZQ==?=
Guest
Posts: n/a
 
      06-07-2004
Hardcoded domain before cookie was sent to browser and still have same problem. The path is set to "/"

Mik

----- John Saunders wrote: ----

"Mike" <> wrote in messag
news:1E1979C5-DDF8-4A8C-A137-..
>> I have tracked it down to the code in the global.asax. If i commen

out the Application_AuthenticateRequest code the user is redirected to th
login page after the authentication ticket has expired. I don't know why th
cookie is in the Request object as it should have expired and never sent t
the server. Is this a bug in MS's example or in the way that the expiratio
time is set on the cookie or in the fact that the cookie is being sent t
the server??? Thanks

Check on the domain being assigned to the cookie. If you get differen
results based on the URL, it's probably a domain problem (though there's
small chance it could be a path problem)
--
John Saunder
johnwsaundersiii at hotmai



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Forms Authentication non-persistent cookie not expiring after closingthe browser rh.krish@gmail.com ASP .Net 3 04-10-2008 07:41 AM
Forms Authentication non-persistent cookie not expiring after closing the browser rh.krish ASP .Net 0 04-09-2008 05:23 AM
forms authentication -- expired forms cookie vs. not provided forms cookie Eric ASP .Net Security 2 01-27-2006 10:09 PM
Forms Authenication and single sign on LouB ASP .Net 0 03-11-2005 01:30 PM
Forms Authenication Cookie expires randomly (only on production server) Pete ASP .Net Security 0 12-01-2003 09:40 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57