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. Regarding Sessions..

Regarding Sessions..

Scheduled Pinned Locked Moved ASP.NET
help
12 Posts 6 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.
  • R Offline
    R Offline
    Ron S
    wrote on last edited by
    #1

    Hello ALL, I am creating a webpage, which has two pages. First i login and set the sessionvariable to some value, it will redirect me to page two. I will logout and set the session value to null, my problem here is when i click back in browser after logging out it is going to page two this should not happen. please give me some idea to avoid this. Thanks in advance

    Bharath.S Ron

    S N V U 4 Replies Last reply
    0
    • R Ron S

      Hello ALL, I am creating a webpage, which has two pages. First i login and set the sessionvariable to some value, it will redirect me to page two. I will logout and set the session value to null, my problem here is when i click back in browser after logging out it is going to page two this should not happen. please give me some idea to avoid this. Thanks in advance

      Bharath.S Ron

      S Offline
      S Offline
      S A R I T H
      wrote on last edited by
      #2

      simply... check in page_load event is session variable is null or not if it is null redirect the page to login..thats all

      Sarith...

      1 Reply Last reply
      0
      • R Ron S

        Hello ALL, I am creating a webpage, which has two pages. First i login and set the sessionvariable to some value, it will redirect me to page two. I will logout and set the session value to null, my problem here is when i click back in browser after logging out it is going to page two this should not happen. please give me some idea to avoid this. Thanks in advance

        Bharath.S Ron

        N Offline
        N Offline
        N a v a n e e t h
        wrote on last edited by
        #3

        Bharath.S.Ron wrote:

        I will logout and set the session value to null,

        Wrong. You should call Session.Abandon()

        Bharath.S.Ron wrote:

        my problem here is when i click back in browser after logging out it is going to page two this should not happen.

        You are seeing cached version of your page by browser. In each page_load event you need to check session existence. If it's not exist, navigate user to login page. Your session check would be like this

        if(Session["UserId"]==null)
        {
        Response.Redirect("Login.aspx");
        }


        My Website | Ask smart questions

        R 1 Reply Last reply
        0
        • R Ron S

          Hello ALL, I am creating a webpage, which has two pages. First i login and set the sessionvariable to some value, it will redirect me to page two. I will logout and set the session value to null, my problem here is when i click back in browser after logging out it is going to page two this should not happen. please give me some idea to avoid this. Thanks in advance

          Bharath.S Ron

          V Offline
          V Offline
          VanithaVasu
          wrote on last edited by
          #4

          You have to check in each page load whether the session is null or not null. If the session value is null means redirect to login page else to the required page.

          VanithaVasu

          N 1 Reply Last reply
          0
          • N N a v a n e e t h

            Bharath.S.Ron wrote:

            I will logout and set the session value to null,

            Wrong. You should call Session.Abandon()

            Bharath.S.Ron wrote:

            my problem here is when i click back in browser after logging out it is going to page two this should not happen.

            You are seeing cached version of your page by browser. In each page_load event you need to check session existence. If it's not exist, navigate user to login page. Your session check would be like this

            if(Session["UserId"]==null)
            {
            Response.Redirect("Login.aspx");
            }


            My Website | Ask smart questions

            R Offline
            R Offline
            Ron S
            wrote on last edited by
            #5

            When i click the browser back button the page load event is not triggered ,the page will be directly loaded over the browser.

            Bharath.S Ron

            N 1 Reply Last reply
            0
            • V VanithaVasu

              You have to check in each page load whether the session is null or not null. If the session value is null means redirect to login page else to the required page.

              VanithaVasu

              N Offline
              N Offline
              N a r e s h P a t e l
              wrote on last edited by
              #6

              Hi, The real problem here is that the When he logout then the page is redirects to the Login page but,If he clicks the browser's back buttion then He can view the content of the page. Your Idea --putting some code to page load event will not work here because it comes form the Browser's Cache memory. So it will display. Ok

              Naresh Patel

              1 Reply Last reply
              0
              • R Ron S

                When i click the browser back button the page load event is not triggered ,the page will be directly loaded over the browser.

                Bharath.S Ron

                N Offline
                N Offline
                N a v a n e e t h
                wrote on last edited by
                #7

                Bharath.S.Ron wrote:

                When i click the browser back button the page load event is not triggered

                Yes it won't be fired. But since you are checking Session on page load, he/she can't continue with any other operation. If they click on any button's or refresh the page, it will redirect to login page. You can try disabling the caching too. But I doesn't looks like a good solution to me.


                My Website | Ask smart questions

                1 Reply Last reply
                0
                • R Ron S

                  Hello ALL, I am creating a webpage, which has two pages. First i login and set the sessionvariable to some value, it will redirect me to page two. I will logout and set the session value to null, my problem here is when i click back in browser after logging out it is going to page two this should not happen. please give me some idea to avoid this. Thanks in advance

                  Bharath.S Ron

                  U Offline
                  U Offline
                  Urs Enzler
                  wrote on last edited by
                  #8

                  You can disable caching on the client:

                  Response.CacheControl = "no-cache";
                  Response.AddHeader("pragma", "no-cache");
                  Response.Expires = -1;

                  Then the click on Back will cause a request to the server.

                  -^-^-^-^-^- no risk no funk ................... please vote ------>

                  R 1 Reply Last reply
                  0
                  • U Urs Enzler

                    You can disable caching on the client:

                    Response.CacheControl = "no-cache";
                    Response.AddHeader("pragma", "no-cache");
                    Response.Expires = -1;

                    Then the click on Back will cause a request to the server.

                    -^-^-^-^-^- no risk no funk ................... please vote ------>

                    R Offline
                    R Offline
                    Ron S
                    wrote on last edited by
                    #9

                    can you please brief me on this concept.??

                    Bharath.S Ron

                    U 1 Reply Last reply
                    0
                    • R Ron S

                      can you please brief me on this concept.??

                      Bharath.S Ron

                      U Offline
                      U Offline
                      Urs Enzler
                      wrote on last edited by
                      #10

                      Please refer to the MSDN for information about this methods. The effect is that the Browser does not hold a copy of the page in its cache and therefore requests the page from the server when the user clicks on the back button. And you can react as you wish on the server side - show login screen or whatever you like.

                      -^-^-^-^-^- no risk no funk ................... please vote ------>

                      N 1 Reply Last reply
                      0
                      • U Urs Enzler

                        Please refer to the MSDN for information about this methods. The effect is that the Browser does not hold a copy of the page in its cache and therefore requests the page from the server when the user clicks on the back button. And you can react as you wish on the server side - show login screen or whatever you like.

                        -^-^-^-^-^- no risk no funk ................... please vote ------>

                        N Offline
                        N Offline
                        N a v a n e e t h
                        wrote on last edited by
                        #11

                        Yes you are right, But this method will fail with firefox browser. Any other alternative do you know for firefox ?


                        My Website | Ask smart questions

                        U 1 Reply Last reply
                        0
                        • N N a v a n e e t h

                          Yes you are right, But this method will fail with firefox browser. Any other alternative do you know for firefox ?


                          My Website | Ask smart questions

                          U Offline
                          U Offline
                          Urs Enzler
                          wrote on last edited by
                          #12

                          It's new to me that this approach fails with Firefox :omg: I'll have to check this because this is no good news for my applications! Thanks for the hint.

                          -^-^-^-^-^- no risk no funk ................... please vote ------>

                          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