How to check whether a session exists or not?

Total Post:47

Points:331
 2471  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. Post:131

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

      Modified On Mar-29-2018 02:13:45 AM
  1. Post:47

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

    thank you

Answer

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.