Something I am doing with Session seems funky

Discussion in 'ASP General' started by Stephanie Stowe, Apr 7, 2004.

  1. I am reading some data from a database and placing the values into session
    variables. See code:

    dim lngSessionID, pStr

    pStr = "private, no-cache, must-revalidate"
    Response.ExpiresAbsolute = #2000-01-01#
    Response.AddHeader "pragma", "no-cache"
    Response.AddHeader "cache-control", pStr



    ' Get the return cookie. If the return cookie is set, then coming BACK.
    If Request.Cookies("JSPAccessed") = "Yes" then <-- This is evaluated as
    true. (I did not include the other subs as they are not executed and not
    part of the problem.
    DoReturn
    else
    WriteSessionInfo
    WriteIdentifierCookie
    end if



    Sub DoReturn


    dim strSQL, rs, strSessionID, strLoadPage, sessitem


    strSessionID = Request.Cookies("MyID")


    Response.Cookies("JSPAccess").Expires = #2000-01-01#


    ' Get the service to return to.
    strSQL = "select M.ASPSessionID, S.LoadPage FROM Stowe.SessionMgr As M
    INNER JOIN Stowe.SessionSources As S ON M.SourceService = S.SourceName " & _
    "WHERE M.SessionID = " & strsessionid

    set rs = cn.execute(strSQL)
    strLoadPage = "../" & trim(rs("LoadPage").value)


    if rs("ASPSessionID").value <> session.SessionID then
    Session.abandon ' "delete" stuff which was initialized in Session_OnStart
    strsql = "Select * FROM Stowe.SessionDetail Where SessionID=" &
    strSessionID
    set rs = cn.execute(strSQL)
    do while not rs.eof


    Session(rs("VarName").value) = rs("VarValue").value
    rs.movenext
    loop


    for each sessitem in Session.Contents
    Response.Write sessitem & " - " & session.Contents(sessitem) & "<BR>"
    next
    Response.End


    end if


    rs.close
    set rs = nothing




    Response.Redirect strLoadPage

    End Sub



    ---------------------------------

    In this segment,

    for each sessitem in Session.Contents
    Response.Write sessitem & " - " & session.Contents(sessitem) & "<BR>"
    next
    Response.End

    I am writing the contents of the session for testing so I can see what is in
    it. I am seeing each item twice with different values. I am trying to
    understand why. I see:

    AUTH - True
    ROLE - Borr
    SchoolID - 0
    SchoolName -
    Attempts - 1
    UserID - 0
    EFC_Year - 2001
    EFCTest - False
    PersonID - xxx
    SSN - xxx
    UserType - N
    AUTH - True
    ROLE - Borr
    SchoolID - 0
    SchoolName -
    Attempts - 1
    UserID - 0
    EFC_Year - 2001
    EFCTest - False
    PersonID - xxx
    SSN - xxx
    UserType - N


    Why am I seeing the set of session vars writing to the browser twice? I can
    see in the database from whcih the values are retrieved that there are 11
    and they match a single set from AUTH through UserType.

    I would like to understand this so I am not messing up my session.

    Please note that there is not a single other response.write in the rest of
    the code. For what that is worth...

    Thanks

    S
     
    Stephanie Stowe, Apr 7, 2004
    #1
    1. Advertising

  2. Never thee mind.... I figured it out. I had a session.abandon. DOH. After
    the Session.Abandon, Session_OnStart was firing. Geeesh.

    Sorry to waste time.

    S
    "Stephanie Stowe" <> wrote in message
    news:...
    > I am reading some data from a database and placing the values into session
    > variables. See code:
    >
    > dim lngSessionID, pStr
    >
    > pStr = "private, no-cache, must-revalidate"
    > Response.ExpiresAbsolute = #2000-01-01#
    > Response.AddHeader "pragma", "no-cache"
    > Response.AddHeader "cache-control", pStr
    >
    >
    >
    > ' Get the return cookie. If the return cookie is set, then coming BACK.
    > If Request.Cookies("JSPAccessed") = "Yes" then <-- This is evaluated

    as
    > true. (I did not include the other subs as they are not executed and not
    > part of the problem.
    > DoReturn
    > else
    > WriteSessionInfo
    > WriteIdentifierCookie
    > end if
    >
    >
    >
    > Sub DoReturn
    >
    >
    > dim strSQL, rs, strSessionID, strLoadPage, sessitem
    >
    >
    > strSessionID = Request.Cookies("MyID")
    >
    >
    > Response.Cookies("JSPAccess").Expires = #2000-01-01#
    >
    >
    > ' Get the service to return to.
    > strSQL = "select M.ASPSessionID, S.LoadPage FROM Stowe.SessionMgr As M
    > INNER JOIN Stowe.SessionSources As S ON M.SourceService = S.SourceName " &

    _
    > "WHERE M.SessionID = " & strsessionid
    >
    > set rs = cn.execute(strSQL)
    > strLoadPage = "../" & trim(rs("LoadPage").value)
    >
    >
    > if rs("ASPSessionID").value <> session.SessionID then
    > Session.abandon ' "delete" stuff which was initialized in

    Session_OnStart
    > strsql = "Select * FROM Stowe.SessionDetail Where SessionID=" &
    > strSessionID
    > set rs = cn.execute(strSQL)
    > do while not rs.eof
    >
    >
    > Session(rs("VarName").value) = rs("VarValue").value
    > rs.movenext
    > loop
    >
    >
    > for each sessitem in Session.Contents
    > Response.Write sessitem & " - " & session.Contents(sessitem) & "<BR>"
    > next
    > Response.End
    >
    >
    > end if
    >
    >
    > rs.close
    > set rs = nothing
    >
    >
    >
    >
    > Response.Redirect strLoadPage
    >
    > End Sub
    >
    >
    >
    > ---------------------------------
    >
    > In this segment,
    >
    > for each sessitem in Session.Contents
    > Response.Write sessitem & " - " & session.Contents(sessitem) & "<BR>"
    > next
    > Response.End
    >
    > I am writing the contents of the session for testing so I can see what is

    in
    > it. I am seeing each item twice with different values. I am trying to
    > understand why. I see:
    >
    > AUTH - True
    > ROLE - Borr
    > SchoolID - 0
    > SchoolName -
    > Attempts - 1
    > UserID - 0
    > EFC_Year - 2001
    > EFCTest - False
    > PersonID - xxx
    > SSN - xxx
    > UserType - N
    > AUTH - True
    > ROLE - Borr
    > SchoolID - 0
    > SchoolName -
    > Attempts - 1
    > UserID - 0
    > EFC_Year - 2001
    > EFCTest - False
    > PersonID - xxx
    > SSN - xxx
    > UserType - N
    >
    >
    > Why am I seeing the set of session vars writing to the browser twice? I

    can
    > see in the database from whcih the values are retrieved that there are 11
    > and they match a single set from AUTH through UserType.
    >
    > I would like to understand this so I am not messing up my session.
    >
    > Please note that there is not a single other response.write in the rest of
    > the code. For what that is worth...
    >
    > Thanks
    >
    > S
    >
    >
     
    Stephanie Stowe, Apr 7, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Diogenes Dilone

    Funky error Situation

    Diogenes Dilone, Jan 6, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    553
    Diogenes Dilone
    Jan 7, 2004
  2. =?Utf-8?B?VHJhY3k=?=

    Funky address change.

    =?Utf-8?B?VHJhY3k=?=, Mar 16, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    397
    Juan T. Llibre
    Mar 16, 2006
  3. iksrazal

    funky but simple regex

    iksrazal, Jul 19, 2004, in forum: Java
    Replies:
    3
    Views:
    403
    iksrazal
    Jul 20, 2004
  4. dwilson
    Replies:
    0
    Views:
    1,260
    dwilson
    Apr 8, 2005
  5. Johnfli

    something funky

    Johnfli, May 2, 2006, in forum: ASP General
    Replies:
    9
    Views:
    164
    Mike Brind
    May 3, 2006
Loading...

Share This Page