Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts

    What's happening to my session variables?

    Is there something about session variables accross directories? I know that sounds daft, but I don't get this:

    www.mysite.com/directory/test.asp
    Code:
    <%
    session("foo")="one"
    response.write(session("foo"))
    response.write(session("baa"))
    %>

    www.mysite.com/different_directory/test.asp
    Code:
    <%
    session("baa")="two"
    response.write(session("foo"))
    response.write(session("baa"))
    %>

    No matter how many times I hit those pages in succession, neither page can see the session variable that the other one is populating. Why?

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    ASP thinks it's a new application unless you specifically set them up to share with Global.asa.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts
    do you allow unwritten cookies in your browser settings?

    you dont need the global.asa file but if you have <%@ ENABLESESSIONSSTATE = False %> at the top of your page then you will get a new session id with each page and therefore will not be able to carry session variables from page to page.


    If i remember correctly if you have that on one page and then change pages the value will remain false until which time you have a page with <%@ ENABLESESSIONSSTATE = True %> at which point you should be able to start using session variables again.


  •  

    Posting Permissions

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