Search code examples
c#htmlasp.netvb.netweb-applications

Is it possible to check or clear session variables from an HTML page?


I have a web application that uses Visual Basic 2008, C#, and the ASP.NET 3.5 Framework. It consists of five pages:

  1. Index (Index.html)
  2. About us (AboutUs.html)
  3. Contact us (ContactUs.html)
  4. User login (Login.aspx)
  5. User home (UserHome.aspx)

All pages contain a menu to navigate to all other pages.

Is it possible to clear a session from an HTML page? If a user logs in, navigates to the Contact Us page, then logs out from that page, how can I clear session variables?


Solution

  • No, Sessions are server-side variables and can not be changed in the client-side.

    Here are some tips:

    1. Use masterpages
    2. You can use HttpXmlRequest to clear the session
    3. Redirect user to page (for example logout.aspx) and in its code behind, in onLoad Method put this code:

    Session["UserId"] = null; Response.Redirect("Index.html",true);