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. Session logout problem

Session logout problem

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethelpquestion
29 Posts 9 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.
  • T TommyTomToms

    Put this in your Page Load event : Response.Expires = 0; Response.ExpiresAbsolute = DateTime.Now;

    V Offline
    V Offline
    VijayVishwakarma
    wrote on last edited by
    #21

    Apologies to bother you but can you please brief me where? On which page? Regards

    Vijay V. Yash Softech

    T 1 Reply Last reply
    0
    • V VijayVishwakarma

      Apologies to bother you but can you please brief me where? On which page? Regards

      Vijay V. Yash Softech

      T Offline
      T Offline
      TommyTomToms
      wrote on last edited by
      #22

      You can place it on all the pages you are using in the Page Load event. (probably could to this in the HttpModule) protected void Page_Load(object sender, EventArgs e) { Response.Expires = 0; Response.ExpiresAbsolute = DateTime.Now; if (Session["User"] != null) { //some other code... } else { //Redirect to Login Page } } The on the Logout button if the Sessions are "Abandoned" and the user tries navigating Back to this page he will be re-directed (asked for login credentials)... Hope this helps

      V 1 Reply Last reply
      0
      • T TommyTomToms

        You can place it on all the pages you are using in the Page Load event. (probably could to this in the HttpModule) protected void Page_Load(object sender, EventArgs e) { Response.Expires = 0; Response.ExpiresAbsolute = DateTime.Now; if (Session["User"] != null) { //some other code... } else { //Redirect to Login Page } } The on the Logout button if the Sessions are "Abandoned" and the user tries navigating Back to this page he will be re-directed (asked for login credentials)... Hope this helps

        V Offline
        V Offline
        VijayVishwakarma
        wrote on last edited by
        #23

        thanks for the reply. But this too is not working. I have added the code in the page load and on logout have used Session.Abandon(). After logout I tried back button its again in. Only IE is not allowing the user to go back in but other browsers like Mozilla, Opera are allowing to go back in however I cannot do anything but I dont want user to go in after loggin out.

        Vijay V. Yash Softech

        V 1 Reply Last reply
        0
        • V VijayVishwakarma

          thanks for the reply. But this too is not working. I have added the code in the page load and on logout have used Session.Abandon(). After logout I tried back button its again in. Only IE is not allowing the user to go back in but other browsers like Mozilla, Opera are allowing to go back in however I cannot do anything but I dont want user to go in after loggin out.

          Vijay V. Yash Softech

          V Offline
          V Offline
          VijayVishwakarma
          wrote on last edited by
          #24

          One thing I noticed that page load is not called when User presses the back button.So this means the page load is not called when a browsers back button is pressed. And thus the code to check Session value is not called and the user is in. May be I have to use the Session code on any other page function. Can anyone suggest me on this? Regards

          Vijay V. Yash Softech

          T 1 Reply Last reply
          0
          • V VijayVishwakarma

            One thing I noticed that page load is not called when User presses the back button.So this means the page load is not called when a browsers back button is pressed. And thus the code to check Session value is not called and the user is in. May be I have to use the Session code on any other page function. Can anyone suggest me on this? Regards

            Vijay V. Yash Softech

            T Offline
            T Offline
            TommyTomToms
            wrote on last edited by
            #25

            I noticed that too.. Mozilla is a strange animal :) What I found that could possibly work is to add javascript function on the document Onload event... onload="CheckSessions()" then through your javascript function click some hidden server button to re check the sessions (this will cause a Postback). function CheckSessions() { document.getElementById("btnCheck").click(); } This is a bit of a hack but it works... javascript fires even after navigating back... PS: I noticed that the navigating doesnt call the Page_Load or Page_Init :(

            T V 2 Replies Last reply
            0
            • T TommyTomToms

              I noticed that too.. Mozilla is a strange animal :) What I found that could possibly work is to add javascript function on the document Onload event... onload="CheckSessions()" then through your javascript function click some hidden server button to re check the sessions (this will cause a Postback). function CheckSessions() { document.getElementById("btnCheck").click(); } This is a bit of a hack but it works... javascript fires even after navigating back... PS: I noticed that the navigating doesnt call the Page_Load or Page_Init :(

              T Offline
              T Offline
              TommyTomToms
              wrote on last edited by
              #26

              ooops that will go into an infinite loop :-O

              A 1 Reply Last reply
              0
              • T TommyTomToms

                ooops that will go into an infinite loop :-O

                A Offline
                A Offline
                Abhishek Sur
                wrote on last edited by
                #27

                I think making Session.Abandon and checking for some session value from the Application.BiginRequest event will do the purpose. Check if session exists, or otherwise redirect to login screen...

                Abhishek Sur

                V 1 Reply Last reply
                0
                • A Abhishek Sur

                  I think making Session.Abandon and checking for some session value from the Application.BiginRequest event will do the purpose. Check if session exists, or otherwise redirect to login screen...

                  Abhishek Sur

                  V Offline
                  V Offline
                  VijayVishwakarma
                  wrote on last edited by
                  #28

                  This lead to an infinite loop. Regards

                  Vijay V. Yash Softech

                  1 Reply Last reply
                  0
                  • T TommyTomToms

                    I noticed that too.. Mozilla is a strange animal :) What I found that could possibly work is to add javascript function on the document Onload event... onload="CheckSessions()" then through your javascript function click some hidden server button to re check the sessions (this will cause a Postback). function CheckSessions() { document.getElementById("btnCheck").click(); } This is a bit of a hack but it works... javascript fires even after navigating back... PS: I noticed that the navigating doesnt call the Page_Load or Page_Init :(

                    V Offline
                    V Offline
                    VijayVishwakarma
                    wrote on last edited by
                    #29

                    this is not working for me. Can you suggest any other alternate? IE works fine I have problem with other browsers. I am using cookies to maintain login. Regards

                    Vijay V. Yash Softech

                    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