HOW TO CHECK WHETHER A SESSION EXISTS OR NOT?

Pooja Malohtra

Total Post:47

Points:331
Posted by  Pooja Malohtra
 2061  View(s)
Ratings:
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.

  1. Uttam Misra

    Post:126

    Points:906
    Re: How to check whether a session exists or not?

    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();
            }
        }

  1. Pooja Malohtra

    Post:47

    Points:331
    Re: How to check whether a session exists or not?

    thank you

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!