Why Im losing session variables values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • edwin809
    New Member
    • Jul 2008
    • 3

    Why Im losing session variables values

    After the authentication process I stored the login flags using session variables to check when a user its logged or not but between pages doing from submit or response.redire ct, the script kicks out the users.

    I use on the top of each page:
    If Session("logged ") <> "Yes" Then Response.Redire ct("default.asp ") End If

    but sometimes this occurs I had put already the timeout to 2 hours and that doesnt fix the problem. Anyone knows what could be?
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    What is your IDE? Some consider each page a distinct site, this doesn't allow session variables to be shared...

    Jared

    Comment

    • edwin809
      New Member
      • Jul 2008
      • 3

      #3
      the server its win 2003 server and I am programing using vbscript ASP 3.0

      Comment

      • jhardman
        Recognized Expert Specialist
        • Jan 2007
        • 3405

        #4
        Originally posted by edwin809
        the server its win 2003 server and I am programing using vbscript ASP 3.0
        Are you just just typing your code in notepad, or are you using some integrated development environment?

        Jared

        Comment

        • edwin809
          New Member
          • Jul 2008
          • 3

          #5
          Originally posted by jhardman
          Are you just just typing your code in notepad, or are you using some integrated development environment?

          Jared
          Im using Dreamwaver as editor.

          Edwin

          Comment

          • jhardman
            Recognized Expert Specialist
            • Jan 2007
            • 3405

            #6
            Originally posted by edwin809
            Im using Dreamwaver as editor.

            Edwin
            That's the problem. DW makes each of the pages a different virtual web site, they don't share session variables. One of the experts on the forum found a way around this, I think it was drbunchman or medicineworker, I'll ask them to look in on this thread. Personally I never use dreamweaver because I prefer to have all the control over my site instead of coasting through on auto. I like driving with a manual transmission too...

            Jared

            Comment

            • DrBunchman
              Recognized Expert Contributor
              • Jan 2008
              • 979

              #7
              This rings a tiny bell with me but I can't remember if it was something I'd written or something I'd read on the site. Either way I can't recall the solution now but I'll have a look and see if anything jogs my memory.

              Hopefully medicineworker will be better able to help...

              Dr B

              Comment

              • jeffstl
                Recognized Expert Contributor
                • Feb 2008
                • 432

                #8
                Subscribing...

                I too would be curious to know why it matters what editor you are using when considering why session variables may not be working.

                After all the .asp files are uploaded and executed on the server. What does DW have to do with that?

                Comment

                • jhardman
                  Recognized Expert Specialist
                  • Jan 2007
                  • 3405

                  #9
                  Originally posted by jeffstl
                  Subscribing...

                  I too would be curious to know why it matters what editor you are using when considering why session variables may not be working.

                  After all the .asp files are uploaded and executed on the server. What does DW have to do with that?
                  DW doesn't just create plain text .ASP files, it creates folders and sets permissions. If you wanted, you could copy the code into fresh ASP files in a blank directory and it would probably work. I believe the problem is that DW is creating the different pages as different sites in different folders with different web.config files. All of this means that the session variables are considered specific to one page, not across the whole web-app.

                  When I first heard of this bug, DW wasn't the main culprit, but I think this is the same problem.

                  Edwin809, to test really quickly if this is indeed the problem, type up this code in notepad and save it as sessionTest.asp in any folder you want to test:
                  [code=asp]<%
                  for each x in session.content s
                  response.write x & ": " & session(x) & "<br>" & vbNewLine
                  next %>
                  [/code]If I am right, only the variables that were set in asp pages in the same virtual directory will show up.

                  Jared
                  Last edited by jhardman; Aug 4 '08, 06:15 PM. Reason: fixed error in code

                  Comment

                  • jeffstl
                    Recognized Expert Contributor
                    • Feb 2008
                    • 432

                    #10
                    Oh I see. Interesting

                    I guess I've never come across the problem because almost all the asp apps I've worked on never had any subdirectories, but all .asp files were located in the wwwroot folder on my IIS box, and subsequently I had my local directory the same way.

                    Thanks for this info !!!!

                    Comment

                    • JamieHowarth0
                      Recognized Expert Contributor
                      • May 2007
                      • 537

                      #11
                      Don't think it was me that had a problem with this, but I haven't touched classic ASP for a good few months now, I'm a born-again .NET man...

                      However, moving between pages in different virtual directories, and if DW sets each one up as a sub-app, will screw up session variables. Session variables have the scope of a single app, and if DW is setting up virtual directories (and subsequent sub-apps and new app pools) for you, then good luck trying to manage it.

                      I'm still a Notepad and IIS kinda guy!

                      med

                      Comment

                      Working...