CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Jun 2006
    Posts
    130

    Destroy sessions

    I use session variables for keeping track whether a user has logged in or not. When someone logs out, I set Session["SOME_VAR"] = null. Then, on all other pages, I check whether Session["SOME_VAR"] exists. This works fine in firefox/explorer, but not in opera, it seems like I still can log in, even when I put Session[".."] = null. Is there any other way to destroy sessions?

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Destroy sessions

    You should be doing Session.Clear() rather than just setting the values to null. That is the preferred way.

  3. #3
    Join Date
    Jun 2006
    Posts
    130

    Re: Destroy sessions

    Yeah but the things is that I want many session variables. For instance, first I want the user to log in. In case of success, I want him to choose a background, and so on. So I need many variables and some of them should be "null" or "not set". I doint want to clear the entire session. What should I set them to to indicate that they have not been set, and how do I check that? (if the null-way is no good)

  4. #4
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Destroy sessions

    Quote Originally Posted by EEKstream
    Yeah but the things is that I want many session variables. For instance, first I want the user to log in. In case of success, I want him to choose a background, and so on. So I need many variables and some of them should be "null" or "not set". I doint want to clear the entire session. What should I set them to to indicate that they have not been set, and how do I check that? (if the null-way is no good)
    Can you show the code how you are checking whether a session variable is blank/null.

  5. #5
    Join Date
    Jun 2006
    Posts
    130

    Re: Destroy sessions

    okey, so for instance, when I go to the select background page, I do something like
    Code:
    if(Session["LOGGEDIN"] == null || !(bool)Session["LOGGEDIN"])
        Response.Redirect("Login.aspx", false);
    and on my mainpage, where I need to be logged in And have a background

    Code:
    if(Session["LOGGEDIN"] == null || !(bool)Session["LOGGEDIN"] || Session["Background"] == null)
        Response.Redirect("Login.aspx", false);
    It works great in Firefox and IE, but not in opera. I need some way to say "the background-variable is not set!" and then check whether it's set or not

  6. #6
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Destroy sessions

    The code looks ok to me. And if it is working in IE and FireFox then there must be issue with Opera Settings. You should check the settings, etc in Opera. I don't use Opera so I can't be in a position to judge what is wrong.

  7. #7
    Join Date
    Jun 2006
    Posts
    130

    Re: Destroy sessions

    Okey thanks. Who cares about a few Opera-suckers anyway

  8. #8
    Join Date
    Jul 2006
    Posts
    19

    Re: Destroy sessions

    Hard to imagine that this is a problem of Opera (or a client) since
    the code you've posted is executed on the server...

    if it works on any browser it actually must work on every browser.

  9. #9
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Destroy sessions

    Quote Originally Posted by AndyTheAce
    Hard to imagine that this is a problem of Opera (or a client) since
    the code you've posted is executed on the server...

    if it works on any browser it actually must work on every browser.
    Well when you say Sessions these are basically cookies that are created on the Client-Side and the settings that browser has does make an impact onhow they will behave.

  10. #10
    Join Date
    Jul 2006
    Posts
    19

    Re: Destroy sessions

    True, under this aspect you are right.
    Maybe check HttpCacheability settings.. even if it makes no sense
    if the same page works on other browsers


    Response.Cache.SetCacheability(HttpCacheability.NoCache)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured