Session variables lost across pages

Discussion in 'ASP General' started by Adam, Apr 26, 2004.

  1. Adam

    Adam Guest

    Hi All,

    My Session variables are not being kept across .asp pages.

    I have written two test pages that do nothing else.

    When page two is displayed the Session variable is undefined.

    I have read http://www.aspfaq.com/show.asp?id=2157.
    .. 'Enable session state'is enabled for the website.
    .. I am running IE6 on WinXP SP1. All my browser Security settings
    are set to the default levels.

    What am I missing ?

    Thanks in advance.
    Adam

    TESTONE.ASP

    <%@ language=javascript%>
    <% Response.Buffer = true;%>
    ..
    ..
    <%
    var foo = "foo";
    if (typeof(Session("test")) == 'undefined') {
    Session("test") = foo;
    }
    %>
    <table>
    <tr><td>Session variable test = <%=Session("test")%></td></tr>
    <tr><td><A href="testtwo.asp">Go to page two</a></td></tr>
    </table>
    ..
    ..

    TESTTWO.ASP
    <%@ language=javascript%>
    <% Response.Buffer = true;%>
    ..
    ..
    <table>
    <tr><td><%=typeof(Session("test"))%></td></tr>
    <tr><td>Session variable test = <%=Session("test")%></td></tr>
    </table>
     
    Adam, Apr 26, 2004
    #1
    1. Advertising

  2. Do you get an error that says variable is undefined, or you assuming it's
    undefined because it is empty, null, blank string, etc?

    --
    Aaron Bertrand
    SQL Server MVP
    http://www.aspfaq.com/







    "Adam" <> wrote in message
    news:...
    > Hi All,
    >
    > My Session variables are not being kept across .asp pages.
    >
    > I have written two test pages that do nothing else.
    >
    > When page two is displayed the Session variable is undefined.
    >
    > I have read http://www.aspfaq.com/show.asp?id=2157.
    > . 'Enable session state'is enabled for the website.
    > . I am running IE6 on WinXP SP1. All my browser Security settings
    > are set to the default levels.
    >
    > What am I missing ?
    >
    > Thanks in advance.
    > Adam
    >
    > TESTONE.ASP
    >
    > <%@ language=javascript%>
    > <% Response.Buffer = true;%>
    > .
    > .
    > <%
    > var foo = "foo";
    > if (typeof(Session("test")) == 'undefined') {
    > Session("test") = foo;
    > }
    > %>
    > <table>
    > <tr><td>Session variable test = <%=Session("test")%></td></tr>
    > <tr><td><A href="testtwo.asp">Go to page two</a></td></tr>
    > </table>
    > .
    > .
    >
    > TESTTWO.ASP
    > <%@ language=javascript%>
    > <% Response.Buffer = true;%>
    > .
    > .
    > <table>
    > <tr><td><%=typeof(Session("test"))%></td></tr>
    > <tr><td>Session variable test = <%=Session("test")%></td></tr>
    > </table>
     
    Aaron Bertrand [MVP], Apr 27, 2004
    #2
    1. Advertising

  3. Adam

    J. Baute Guest

    (Adam) wrote in message news:<>...
    > Hi All,
    >
    > My Session variables are not being kept across .asp pages.
    >
    > I have written two test pages that do nothing else.
    >
    > When page two is displayed the Session variable is undefined.
    >
    > I have read http://www.aspfaq.com/show.asp?id=2157.
    > . 'Enable session state'is enabled for the website.
    > . I am running IE6 on WinXP SP1. All my browser Security settings
    > are set to the default levels.
    >
    > What am I missing ?
    >
    > Thanks in advance.
    > Adam
    >
    > TESTONE.ASP
    >
    > <%@ language=javascript%>
    > <% Response.Buffer = true;%>
    > .
    > .
    > <%
    > var foo = "foo";
    > if (typeof(Session("test")) == 'undefined') {
    > Session("test") = foo;
    > }
    > %>
    > <table>
    > <tr><td>Session variable test = <%=Session("test")%></td></tr>
    > <tr><td><A href="testtwo.asp">Go to page two</a></td></tr>
    > </table>
    > .
    > .
    >
    > TESTTWO.ASP
    > <%@ language=javascript%>
    > <% Response.Buffer = true;%>
    > .
    > .
    > <table>
    > <tr><td><%=typeof(Session("test"))%></td></tr>
    > <tr><td>Session variable test = <%=Session("test")%></td></tr>
    > </table>


    try again using a different browser,
    if it doesn't work in eg. Mozilla either, it's not an IE issue (like cookies etc)
     
    J. Baute, Apr 27, 2004
    #3
  4. Adam

    Adam Guest

    "Aaron Bertrand [MVP]" <> wrote in message news:<>...
    > Do you get an error that says variable is undefined, or you assuming it's
    > undefined because it is empty, null, blank string, etc?
    >
    > --
    > Aaron Bertrand
    > SQL Server MVP
    > http://www.aspfaq.com/
    >


    When the test statement is evaluated on TESTONE.ASP, the output is
    "Session variable test = foo"

    On TESTTWO.ASP the variable has been lost so
    typeof(Session("test")) == undefined

    Adam
    >
    >
    >
    >
    >
    > "Adam" <> wrote in message
    > news:...
    > > Hi All,
    > >
    > > My Session variables are not being kept across .asp pages.
    > >
    > > I have written two test pages that do nothing else.
    > >
    > > When page two is displayed the Session variable is undefined.
    > >
    > > I have read http://www.aspfaq.com/show.asp?id=2157.
    > > . 'Enable session state'is enabled for the website.
    > > . I am running IE6 on WinXP SP1. All my browser Security settings
    > > are set to the default levels.
    > >
    > > What am I missing ?
    > >
    > > Thanks in advance.
    > > Adam
    > >
    > > TESTONE.ASP
    > >
    > > <%@ language=javascript%>
    > > <% Response.Buffer = true;%>
    > > .
    > > .
    > > <%
    > > var foo = "foo";
    > > if (typeof(Session("test")) == 'undefined') {
    > > Session("test") = foo;
    > > }
    > > %>
    > > <table>
    > > <tr><td>Session variable test = <%=Session("test")%></td></tr>
    > > <tr><td><A href="testtwo.asp">Go to page two</a></td></tr>
    > > </table>
    > > .
    > > .
    > >
    > > TESTTWO.ASP
    > > <%@ language=javascript%>
    > > <% Response.Buffer = true;%>
    > > .
    > > .
    > > <table>
    > > <tr><td><%=typeof(Session("test"))%></td></tr>
    > > <tr><td>Session variable test = <%=Session("test")%></td></tr>
    > > </table>
     
    Adam, Apr 27, 2004
    #4
  5. Try a test where you set the session variable and then display it on the
    same page as in...

    session("rr_org") = "Hello World"
    response.write "-" & session("rr_org") "-"

    The "-" help to confirm that the var is empty btw.



    J. Baute wrote:
    > (Adam) wrote in message news:<>...
    >
    >>Hi All,
    >>
    >>My Session variables are not being kept across .asp pages.
    >>
    >>I have written two test pages that do nothing else.
    >>
    >>When page two is displayed the Session variable is undefined.
    >>
    >>I have read http://www.aspfaq.com/show.asp?id=2157.
    >>. 'Enable session state'is enabled for the website.
    >>. I am running IE6 on WinXP SP1. All my browser Security settings
    >>are set to the default levels.
    >>
    >>What am I missing ?
    >>
    >>Thanks in advance.
    >>Adam
    >>
    >>TESTONE.ASP
    >>
    >><%@ language=javascript%>
    >><% Response.Buffer = true;%>
    >>.
    >>.
    >><%
    >>var foo = "foo";
    >>if (typeof(Session("test")) == 'undefined') {
    >> Session("test") = foo;
    >>}
    >>%>
    >><table>
    >><tr><td>Session variable test = <%=Session("test")%></td></tr>
    >><tr><td><A href="testtwo.asp">Go to page two</a></td></tr>
    >></table>
    >>.
    >>.
    >>
    >>TESTTWO.ASP
    >><%@ language=javascript%>
    >><% Response.Buffer = true;%>
    >>.
    >>.
    >><table>
    >><tr><td><%=typeof(Session("test"))%></td></tr>
    >><tr><td>Session variable test = <%=Session("test")%></td></tr>
    >></table>

    >
    >
    > try again using a different browser,
    > if it doesn't work in eg. Mozilla either, it's not an IE issue (like cookies etc)
     
    David C. Holley, Apr 27, 2004
    #5
  6. Adam

    Vilmar Guest

    Hi,
    Take a look at your iis webserver and check if it is capable to keep session
    state.
    In Ms-IIS 5.0 the way is:
    properties
    tab base folder
    button configuration
    tab application option
    so activate the option which enable session state.
    bye
    --



    Vilmar Braz√£o de Oliveira

    "Adam" <> escreveu na mensagem
    news:...
    > Hi All,
    >
    > My Session variables are not being kept across .asp pages.
    >
    > I have written two test pages that do nothing else.
    >
    > When page two is displayed the Session variable is undefined.
    >
    > I have read http://www.aspfaq.com/show.asp?id=2157.
    > . 'Enable session state'is enabled for the website.
    > . I am running IE6 on WinXP SP1. All my browser Security settings
    > are set to the default levels.
    >
    > What am I missing ?
    >
    > Thanks in advance.
    > Adam
    >
    > TESTONE.ASP
    >
    > <%@ language=javascript%>
    > <% Response.Buffer = true;%>
    > .
    > .
    > <%
    > var foo = "foo";
    > if (typeof(Session("test")) == 'undefined') {
    > Session("test") = foo;
    > }
    > %>
    > <table>
    > <tr><td>Session variable test = <%=Session("test")%></td></tr>
    > <tr><td><A href="testtwo.asp">Go to page two</a></td></tr>
    > </table>
    > .
    > .
    >
    > TESTTWO.ASP
    > <%@ language=javascript%>
    > <% Response.Buffer = true;%>
    > .
    > .
    > <table>
    > <tr><td><%=typeof(Session("test"))%></td></tr>
    > <tr><td>Session variable test = <%=Session("test")%></td></tr>
    > </table>
     
    Vilmar, Apr 27, 2004
    #6
  7. Please try a different browser, and go through *every* bullet item in
    http://www.aspfaq.com/2157

    If you find out that it was caused by something not in that article, please
    let me know, because it will be news for me.

    --
    Aaron Bertrand
    SQL Server MVP
    http://www.aspfaq.com/





    "Adam" <> wrote in message
    news:...
    > "Aaron Bertrand [MVP]" <> wrote in message
    > news:<>...
    >> Do you get an error that says variable is undefined, or you assuming it's
    >> undefined because it is empty, null, blank string, etc?
    >>
    >> --
    >> Aaron Bertrand
    >> SQL Server MVP
    >> http://www.aspfaq.com/
    >>

    >
    > When the test statement is evaluated on TESTONE.ASP, the output is
    > "Session variable test = foo"
    >
    > On TESTTWO.ASP the variable has been lost so
    > typeof(Session("test")) == undefined
    >
    > Adam
    >>
    >>
    >>
    >>
    >>
    >> "Adam" <> wrote in message
    >> news:...
    >> > Hi All,
    >> >
    >> > My Session variables are not being kept across .asp pages.
    >> >
    >> > I have written two test pages that do nothing else.
    >> >
    >> > When page two is displayed the Session variable is undefined.
    >> >
    >> > I have read http://www.aspfaq.com/show.asp?id=2157.
    >> > . 'Enable session state'is enabled for the website.
    >> > . I am running IE6 on WinXP SP1. All my browser Security settings
    >> > are set to the default levels.
    >> >
    >> > What am I missing ?
    >> >
    >> > Thanks in advance.
    >> > Adam
    >> >
    >> > TESTONE.ASP
    >> >
    >> > <%@ language=javascript%>
    >> > <% Response.Buffer = true;%>
    >> > .
    >> > .
    >> > <%
    >> > var foo = "foo";
    >> > if (typeof(Session("test")) == 'undefined') {
    >> > Session("test") = foo;
    >> > }
    >> > %>
    >> > <table>
    >> > <tr><td>Session variable test = <%=Session("test")%></td></tr>
    >> > <tr><td><A href="testtwo.asp">Go to page two</a></td></tr>
    >> > </table>
    >> > .
    >> > .
    >> >
    >> > TESTTWO.ASP
    >> > <%@ language=javascript%>
    >> > <% Response.Buffer = true;%>
    >> > .
    >> > .
    >> > <table>
    >> > <tr><td><%=typeof(Session("test"))%></td></tr>
    >> > <tr><td>Session variable test = <%=Session("test")%></td></tr>
    >> > </table>
     
    Aaron Bertrand [MVP], Apr 27, 2004
    #7
  8. Adam wrote:
    >
    > ...When page two is displayed the Session variable is undefined...


    Besides the other suggestions, you may want to check the session timeout and
    the Session_OnStart handler in your global.asa. For that matter, put the
    page in an *application* and see if that matters.



    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms. Please do not contact
    me directly or ask me to contact you directly for assistance. If your
    question is worth asking, it's worth posting.
     
    Dave Anderson, Apr 27, 2004
    #8
  9. Adam

    Adam Guest

    Thanks to all who answered.

    A personal Firewall was the cause. Obviuosly blocking what is an
    unkown process at this point.

    The 'fix' came by accident. Hadnt even thought that could be the
    probably as I am running the IIS server locally.

    Thanks,
    Adam
     
    Adam, Apr 28, 2004
    #9
    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. gupta
    Replies:
    1
    Views:
    679
  2. McGeeky
    Replies:
    10
    Views:
    3,691
    McGeeky
    Oct 24, 2005
  3. ubi_comp
    Replies:
    0
    Views:
    2,249
    ubi_comp
    Feb 3, 2006
  4. gom
    Replies:
    5
    Views:
    354
    Bjorn Sagbakken
    Dec 5, 2007
  5. Guest

    Session lost across page

    Guest, Aug 2, 2004, in forum: ASP General
    Replies:
    4
    Views:
    133
    Guest
    Aug 3, 2004
Loading...

Share This Page