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

session

Scheduled Pinned Locked Moved ASP.NET
help
17 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.
  • B baselanfouqa

    tried but still the samething.....

    A Offline
    A Offline
    Abhijit Jana
    wrote on last edited by
    #8

    Check Session Value on Page_Load. Check my Answer :)

    Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

    1 Reply Last reply
    0
    • B baselanfouqa

      tried but still the samething.....

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

      Then the problem could be with Cache. Did you tried the above solution?

      1 Reply Last reply
      0
      • A Abhijit Jana

        During Logoff you should use Session.Abandon() to set all session variable to null and In Page_Load you should check like this if(Session["UserName"] ==null ) Response.Redirect("Login.aspx"); If you need to learn more about session, please read this article Exploring Session in ASP.Net[^] Let me know if you need more help :)

        Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

        B Offline
        B Offline
        baselanfouqa
        wrote on last edited by
        #10

        dear Abhijit Jana, i did what u wrote in fact my code is exactly the same..... but no use.

        N 1 Reply Last reply
        0
        • B baselanfouqa

          dear Abhijit Jana, i did what u wrote in fact my code is exactly the same..... but no use.

          N Offline
          N Offline
          nagendrathecoder
          wrote on last edited by
          #11

          That means Session value is not null. See what is the value of Session.

          1 Reply Last reply
          0
          • D Dinesh Mani

            Let me first understand the problem here - First, you had not validated the session on the main page hence when you entered the URL the main page was displayed. So, you validated the session variable and redirected the user to Login page. Now on the login page only after you sign-in you are able to go to the main page. Now you wish to log-out the user for which you use session["UserName"] = null; but the main page still goes thro'. Am I correct? The problem here is that you should not use session["UserName"] = null; to remove the session variable. You should use Session.Remove("UserName"); HTH!

            B Offline
            B Offline
            baselanfouqa
            wrote on last edited by
            #12

            ok... tried but wont work..

            D 1 Reply Last reply
            0
            • B baselanfouqa

              ok... tried but wont work..

              D Offline
              D Offline
              Dinesh Mani
              wrote on last edited by
              #13

              1. How do you check the Session variable on the main page? If possible post the code here. 2. Does the user actually click the Logout button/link?

              B 1 Reply Last reply
              0
              • D Dinesh Mani

                1. How do you check the Session variable on the main page? If possible post the code here. 2. Does the user actually click the Logout button/link?

                B Offline
                B Offline
                baselanfouqa
                wrote on last edited by
                #14

                1.) if (Session["UserName"] == null) { Response.Redirect("Login.aspx"); } this in main.aspx page_load 2.)sure and the code to logout is :- //Session["UserName"] = null; //Session.Abandon(); Session.Remove("UserName"); Response.Redirect("Login.aspx");

                D A 2 Replies Last reply
                0
                • B baselanfouqa

                  1.) if (Session["UserName"] == null) { Response.Redirect("Login.aspx"); } this in main.aspx page_load 2.)sure and the code to logout is :- //Session["UserName"] = null; //Session.Abandon(); Session.Remove("UserName"); Response.Redirect("Login.aspx");

                  D Offline
                  D Offline
                  Dinesh Mani
                  wrote on last edited by
                  #15

                  Did you step thro' and check what happens in the Page_Load on the main page. Check if Session["UserName"] evaluates to null or if it returns any other value. Are you checking this with-in a IsPostBack check? Can you post the entire Page_Load code? Can you re-phrase what is happening against what is expected?

                  B 1 Reply Last reply
                  0
                  • D Dinesh Mani

                    Did you step thro' and check what happens in the Page_Load on the main page. Check if Session["UserName"] evaluates to null or if it returns any other value. Are you checking this with-in a IsPostBack check? Can you post the entire Page_Load code? Can you re-phrase what is happening against what is expected?

                    B Offline
                    B Offline
                    baselanfouqa
                    wrote on last edited by
                    #16

                    thank u for your consideration but i managed to solve out the problem through emptying the buffer..

                    1 Reply Last reply
                    0
                    • B baselanfouqa

                      1.) if (Session["UserName"] == null) { Response.Redirect("Login.aspx"); } this in main.aspx page_load 2.)sure and the code to logout is :- //Session["UserName"] = null; //Session.Abandon(); Session.Remove("UserName"); Response.Redirect("Login.aspx");

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

                      Please check if session is removed properly.. Check

                      Session.Remove("UserName");
                      var session = Session["UserName"];

                      Check what you see in the session variable. If it is null, I think the session is somewhere created. If you can see the value of session, it is indeed not clearing out properly. Are you using webdev environment. I recommend you to try this in the IIS. :)

                      Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                      My Latest Articles-->** Windows7 API Code Pack
                      Simplify Code Using NDepend
                      Basics of Bing Search API using .NET

                      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