473,411 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Forms Authenication Cookie Not Expiring Correctly

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???
Nov 18 '05 #1
3 2347

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???
Nov 18 '05 #2
"Mike" <an*******@discussions.microsoft.com> wrote in message
news:1E**********************************@microsof t.com...

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
Nov 18 '05 #3
Hardcoded domain before cookie was sent to browser and still have same problem. The path is set to "/"

Mik

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

"Mike" <an*******@discussions.microsoft.com> wrote in messag
news:1E**********************************@microsof t.com..
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

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Joey Powell | last post by:
This message was originally posted to the aspnet.security newsgroup, but no one there has ever heard of this before. That is why I am posting this message here, so that more people will see it... ...
0
by: Joe Bonavita | last post by:
I want the use forms authenication for a specific folder so I'm using a location element in the web.config. If someone tries to access a page in that folder directly, they are brought to a main...
1
by: MB | last post by:
Hi guys, I've been experiencing a problem here with forms authentication. When I am on one of my wesite's http (non-secure pages) everything works fine. However, I am using a Shared SSL provided...
4
by: Amil | last post by:
I'm using Forms authorization. In my <forms> section I have timeout="30", but when I examine the cookie, it shows it expiring in 2055? Why? <authentication mode="Forms"> <forms...
1
by: Charlie | last post by:
Hi: Our portal writes a cookie to browser on login. The cookie is then requested by applications launched by portal as a way of passing credentials. The problem is when logging off portal,...
2
by: pv_kannan | last post by:
I recently found out that my authentication cookies are not expiring even though I have set the persist property to false. As a result, users are able to access the secure websites with indifferent...
0
by: robert | last post by:
I have noticed in .net 2 that when authenticating a user, setting the cookie using either redirectfromloginpage or setauthcookie, specifying true for the persistent parameter that the cookie is...
1
by: Smokey Grindel | last post by:
I want to show a page that says you timed out basically when a user that is authenticated via forms based authentication times out (after 60 minutes of inactivity) how do you do this? right now it...
3
by: rh.krish | last post by:
I have a typical ASP.NET 2.0 Forms authentication application which authenticates against Active Directory. I use non-persistent cookie so that the user is NOT remembered across browser sessions....
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.