Home > DeveloperSection > Forums > How to check whether a session exists or not?
Pooja Malohtra
Pooja Malohtra

Total Post:47

Points:331
Posted on    October-15-2010 7:50 AM

 ASP.Net ASP.Net 
Ratings:


 2 Reply(s)
 1703  View(s)
Rate this:

How to check whether a session exists or not?

I want to do this on each page, if not exist I will just send the user back to the sign in page.



Uttam Misra

Total Post:124

Points:888
Posted on    October-15-2010 8:07 AM

Use this code for Session_Start event in global.asax file:

void Session_Start(object sender, EventArgs e)
    {
        if (User.Identity.IsAuthenticated)
        {
            System.Web.Security.FormsAuthentication.SignOut();
            System.Web.Security.FormsAuthentication.RedirectToLoginPage();
        }
    }


Pooja Malohtra
Pooja Malohtra

Total Post:47

Points:331
Posted on    October-15-2010 8:21 AM

thank you

Don't want to miss updates? Please click the below button!

Follow MindStick