Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to expire a Session if we click Browser Back Button

How to expire a Session if we click Browser Back Button

Scheduled Pinned Locked Moved ASP.NET
tutorial
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kaushik490
    wrote on last edited by
    #1

    Hi Gurus, I have a Login Page. First i have logged in and browsed the Site, then with out Logging out, I navigate to login page by clicking Browers Back Button, Now here when i click Forward button it is logging into the site, But at this point the session should expire. Can any one provide the Code for the above Senario. I will be greatful to u all,

    with thanks and regards, kaushik pulpa

    S C 2 Replies Last reply
    0
    • K kaushik490

      Hi Gurus, I have a Login Page. First i have logged in and browsed the Site, then with out Logging out, I navigate to login page by clicking Browers Back Button, Now here when i click Forward button it is logging into the site, But at this point the session should expire. Can any one provide the Code for the above Senario. I will be greatful to u all,

      with thanks and regards, kaushik pulpa

      S Offline
      S Offline
      Sandeep Akhare
      wrote on last edited by
      #2

      kaushik490 wrote:

      But at this point the session should expire

      When you click Log Out Button make your session =null; Session["UserName"] = null; Session["Password"] = null; Also you can do one thing add this code in every page load event Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetExpires(DateTime.Now); //or a date much earlier OK Are you checking the Session in every page ? i.e validating the user in every page ?

      Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

      K 1 Reply Last reply
      0
      • S Sandeep Akhare

        kaushik490 wrote:

        But at this point the session should expire

        When you click Log Out Button make your session =null; Session["UserName"] = null; Session["Password"] = null; Also you can do one thing add this code in every page load event Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetExpires(DateTime.Now); //or a date much earlier OK Are you checking the Session in every page ? i.e validating the user in every page ?

        Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

        K Offline
        K Offline
        kaushik490
        wrote on last edited by
        #3

        Thanks for ur Reply buddy, I will check it and reply again byeeeeeeeee

        with thanks and regards, kaushik pulpa

        1 Reply Last reply
        0
        • K kaushik490

          Hi Gurus, I have a Login Page. First i have logged in and browsed the Site, then with out Logging out, I navigate to login page by clicking Browers Back Button, Now here when i click Forward button it is logging into the site, But at this point the session should expire. Can any one provide the Code for the above Senario. I will be greatful to u all,

          with thanks and regards, kaushik pulpa

          C Offline
          C Offline
          Chris Maunder
          wrote on last edited by
          #4

          Have you looked at the member functions for the SessionState object[^]? Clear and Abandon may be interesting to you.

          cheers, Chris Maunder

          CodeProject.com : C++ MVP

          R 1 Reply Last reply
          0
          • C Chris Maunder

            Have you looked at the member functions for the SessionState object[^]? Clear and Abandon may be interesting to you.

            cheers, Chris Maunder

            CodeProject.com : C++ MVP

            R Offline
            R Offline
            rama charan
            wrote on last edited by
            #5

            but i think we dint solve the requirement here.The question was how do we expire a session when browser back button is pressed? i would also like to know how to abandon a session in case of browser close event. any suggestion or help is welcome thnks for ur effort

            Rama Charan Prasad "Be happy and Keep smiling.Thats what u want be always..:)"

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups