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. Back button problem

Back button problem

Scheduled Pinned Locked Moved ASP.NET
help
10 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.
  • N Offline
    N Offline
    nour123
    wrote on last edited by
    #1

    Hi All... I have a login page(page1) that checks the user name and his password for a user, when the authorized user goes into the next page(page2)-I initialize an (ID session) and then when he loggs off I empty the session... but, by the back button he could return back again to the 2nd page (and this is the problem )... Could you help me.. Thanks alot... Nour

    C L 2 Replies Last reply
    0
    • N nour123

      Hi All... I have a login page(page1) that checks the user name and his password for a user, when the authorized user goes into the next page(page2)-I initialize an (ID session) and then when he loggs off I empty the session... but, by the back button he could return back again to the 2nd page (and this is the problem )... Could you help me.. Thanks alot... Nour

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      All your pages should check if the user is logged in, and if not, deny access.

      Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

      N 1 Reply Last reply
      0
      • N nour123

        Hi All... I have a login page(page1) that checks the user name and his password for a user, when the authorized user goes into the next page(page2)-I initialize an (ID session) and then when he loggs off I empty the session... but, by the back button he could return back again to the 2nd page (and this is the problem )... Could you help me.. Thanks alot... Nour

        L Offline
        L Offline
        linpihong
        wrote on last edited by
        #3

        you can design a base class to check the session is null or not, then all the pages you use to inherit the base class

        N 1 Reply Last reply
        0
        • C Christian Graus

          All your pages should check if the user is logged in, and if not, deny access.

          Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

          N Offline
          N Offline
          nour123
          wrote on last edited by
          #4

          I did that... But what I need is not to allow the user to go back when back button is pressed... Thanks

          C 1 Reply Last reply
          0
          • L linpihong

            you can design a base class to check the session is null or not, then all the pages you use to inherit the base class

            N Offline
            N Offline
            nour123
            wrote on last edited by
            #5

            I did that... But what I need is not to allow the user to go back when back button is pressed... Thanks

            D 1 Reply Last reply
            0
            • N nour123

              I did that... But what I need is not to allow the user to go back when back button is pressed... Thanks

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              Well, to do that, you simply need to not serve the page if the security check fails.  If they are not logged in, your base page should redirect to the login page.

              Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

              N 1 Reply Last reply
              0
              • C Christian Graus

                Well, to do that, you simply need to not serve the page if the security check fails.  If they are not logged in, your base page should redirect to the login page.

                Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

                N Offline
                N Offline
                nour123
                wrote on last edited by
                #7

                I do that but the problem is: when an autherized user loggen in, and the logged out, he can press the back button and go again to the pages, although the sessions are empty... regards

                C 1 Reply Last reply
                0
                • N nour123

                  I do that but the problem is: when an autherized user loggen in, and the logged out, he can press the back button and go again to the pages, although the sessions are empty... regards

                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #8

                  Well, then you don't 'do that' at all.  If the session is empty, then the only way they can see the page is from the cache.  And there's nothing you can do about that.

                  Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

                  N 1 Reply Last reply
                  0
                  • C Christian Graus

                    Well, then you don't 'do that' at all.  If the session is empty, then the only way they can see the page is from the cache.  And there's nothing you can do about that.

                    Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

                    N Offline
                    N Offline
                    nour123
                    wrote on last edited by
                    #9

                    thanks alot dear

                    1 Reply Last reply
                    0
                    • N nour123

                      I did that... But what I need is not to allow the user to go back when back button is pressed... Thanks

                      D Offline
                      D Offline
                      Dinesh G Jethva1
                      wrote on last edited by
                      #10

                      add following code in body tag onload="history.forward(-1);"

                      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