C# Tutorials and offshore development in India

Tutorials Resources Forum Reviews Interview Jobs Projects Training Your Ad Here


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...




Resources » Code Snippets » C# Syntax »

How to determine a session expired or not


Posted Date: 09 May 2008    Resource Type: Code Snippets    Category: C# Syntax
Author: narasimhaMember Level: Gold    
Rating: 1 out of 5Points: 10



override protected void OnInit(EventArgs e)
{
base.OnInit(e);


//check to see if the Session is null (doesnt exist)
if (Context.Session != null)
{
//check the IsNewSession value, this will tell us if the session has been reset
if (Session.IsNewSession)
{
//now we know it's a new session, so we check to see if a cookie is present
string cookie = Request.Headers["Cookie"];
//now we determine if there is a cookie does it contains what we're looking for
if ((null != cookie) && (cookie.IndexOf("ASP.NET_SessionId") >= 0))
{
//since it's a new session but a ASP.Net cookie exist we know
//the session has expired so we need to redirect them
Response.Redirect("YourURL");
}
}
}
}



Responses to the resource: "How to determine a session expired or not"

No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Check Internet connection present or not
Previous Resource: file uplaod and edit in datagrid
Return to Discussion Resource Index
Post New Resource
Category: C# Syntax


Post resources and earn money!
 
More Resources




About Us    Contact Us    Privacy Policy    Terms Of Use