Session problem - DOTNET

This is a discussion on Session problem - DOTNET ; HI, I have created an application that has a logout.aspx page. here I clear the session variables and redirect the user to the login page, but if I dont close the brower and hit the "back" button. the user is ...

+ Reply to Thread
Results 1 to 3 of 3

Session problem

  1. Default Session problem

    HI,

    I have created an application that has a logout.aspx page. here I clear the
    session variables and redirect the user to the login page, but if I dont
    close the brower and hit the "back" button. the user is directed to the old
    pages.
    How do i avoid this?

    Please advice,
    Stephen



  2. Default Re: Session problem

    Hi,
    On the page load event of each page, check for the session variables.
    If the session variable is empty, then redirect the page to the login page.

    eg)
    private void Page_Load(object sender, System.EventArgs e) {

    if (Session["User_Id"].ToString().Trim().Equals(string.Empty)){

    Response.Redirect("Login.aspx?Msg=Session expired. Please login again.");

    }

    }



    Regards,

    R.Balaji





    "Stephen" <stephenjobs@hotmail.com> wrote in message
    news:u7XNrdqaEHA.2216@TK2MSFTNGP10.phx.gbl...
    > HI,
    >
    > I have created an application that has a logout.aspx page. here I clear

    the
    > session variables and redirect the user to the login page, but if I dont
    > close the brower and hit the "back" button. the user is directed to the

    old
    > pages.
    > How do i avoid this?
    >
    > Please advice,
    > Stephen
    >
    >




  3. Default Re: Session problem

    Taking the code from the IBUYSPY portal's admin/logoff.aspx.cs code-behind
    private void Page_Load(object sender, System.EventArgs e) {

    // Log User Off from Cookie Authentication System

    FormsAuthentication.SignOut();


    // Invalidate roles token

    Response.Cookies["portalroles"].Value = null;

    Response.Cookies["portalroles"].Expires = new System.DateTime(1999, 10, 12);

    Response.Cookies["portalroles"].Path = "/";


    // Redirect user back to the Portal Home Page

    Response.Redirect(Request.ApplicationPath);

    }

    Key points:

    1.. logout
    2.. invalidate the authentication cookie(s) and session variables
    3.. and redirect to a page to prevent the back button from going to a previous page
    This wil not prevent someone to navigate to a cached page in their history, so check for authentication on each page where it is necessary
    "Stephen" <stephenjobs@hotmail.com> wrote in message news:u7XNrdqaEHA.2216@TK2MSFTNGP10.phx.gbl...

    > HI,
    >
    > I have created an application that has a logout.aspx page. here I clear the
    > session variables and redirect the user to the login page, but if I dont
    > close the brower and hit the "back" button. the user is directed to the old
    > pages.
    > How do i avoid this?
    >
    > Please advice,
    > Stephen
    >
    >


+ Reply to Thread

Similar Threads

  1. session problem
    By Application Development in forum PHP
    Replies: 6
    Last Post: 07-27-2007, 04:07 AM
  2. problem with session in IE
    By Application Development in forum PHP
    Replies: 0
    Last Post: 07-16-2007, 07:44 PM
  3. Session problem
    By Application Development in forum DOTNET
    Replies: 4
    Last Post: 07-13-2007, 10:18 AM
  4. Problem: Folder sort order is not retained session to session
    By Application Development in forum Pegasus
    Replies: 0
    Last Post: 10-25-2003, 02:28 AM
  5. IIS Session problem
    By Application Development in forum Inetserver
    Replies: 1
    Last Post: 08-26-2003, 10:24 PM