Lost session variables

Discussion in 'ASP General' started by google@walkerwebworks.co.uk, Feb 1, 2007.

  1. Guest

    I have a website that has a asp secured members only aria that keeps
    session variables to check if someone is logged in or not (if session
    variables are not there then redirect to logon screen) but I also have
    non members aria and I need a way of asking the user if they want to
    move away from the members only aria or go back to it. I have used an
    asp to find out if the page is a non member page and if there is a
    session variable there. If there is a session variable and is a non
    member page then I use JavaScript to bring up a confirm box that if
    the cancel button is pressed then it goes back a page. The problem is
    that when you go back a page the session variable gets lost. Dose
    anyone know how to solve this problem or a better way of doing this?
     
    , Feb 1, 2007
    #1
    1. Advertising

  2. Evertjan. Guest

    wrote on 01 feb 2007 in
    microsoft.public.inetserver.asp.general:

    > I have a website that has a asp secured members only aria that keeps
    > session variables to check if someone is logged in or not (if session
    > variables are not there then redirect to logon screen) but I also have
    > non members aria and I need a way of asking the user if they want to
    > move away from the members only aria or go back to it. I have used an
    > asp to find out if the page is a non member page and if there is a
    > session variable there. If there is a session variable and is a non
    > member page then I use JavaScript to bring up a confirm box that if
    > the cancel button is pressed then it goes back a page. The problem is
    > that when you go back a page the session variable gets lost. Dose
    > anyone know how to solve this problem or a better way of doing this?


    Better show your asp code, only the relevant part, that is.

    If you loose the session, you loose the session variables,
    so I think it is about losing the session.

    The page you come from is or should be stored in:
    Request.ServerVariables("HTTP_REFERER")

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Feb 1, 2007
    #2
    1. Advertising

  3. Guest

    here is my code
    logon is set to 1 in a include that is only on member pages

    <%if logon<>1 then
    if session("user_ID") <> 0 OR Session("user_ID") <> "" then
    %>

    <script type="text/javascript">
    var r=confirm("are you shure you want to leave the secure area?")
    if (r==true)
    {
    }
    else
    {
    history.go(-1)
    }

    </script>
    <% end if
    else %>
    a members menu bar include
    <%end if %>
     
    , Feb 1, 2007
    #3
  4. Evertjan. Guest

    wrote on 01 feb 2007 in
    microsoft.public.inetserver.asp.general:

    > here is my code
    > logon is set to 1 in a include that is only on member pages
    >
    > <%if logon<>1 then



    > if session("user_ID") <> 0 OR Session("user_ID") <> "" then


    This boolean is always true!!!!

    The boolean can only be false,
    if session("user_ID") is both 0 and "" at the same time,
    which is impossible.


    > %>
    >
    > <script type="text/javascript">
    > var r=confirm("are you shure you want to leave the secure area?")
    > if (r==true)
    > {
    > }
    > else
    > {
    > history.go(-1)
    > }
    >
    > </script>
    > <% end if
    > else %>
    > a members menu bar include
    > <%end if %>
    >
    >




    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Feb 1, 2007
    #4
  5. "Evertjan." <> wrote in message
    news:Xns98CAA4C8FE883eejj99@194.109.133.242...
    > wrote on 01 feb 2007 in
    > microsoft.public.inetserver.asp.general:
    >
    > > here is my code
    > > logon is set to 1 in a include that is only on member pages
    > >
    > > <%if logon<>1 then

    >
    >
    > > if session("user_ID") <> 0 OR Session("user_ID") <> "" then

    >
    > This boolean is always true!!!!
    >
    > The boolean can only be false,
    > if session("user_ID") is both 0 and "" at the same time,
    > which is impossible.
    >


    Are you sure? What if Session("User_ID") is empty?

    This code would be better:-

    If Session("User_ID") = Empty Then
     
    Anthony Jones, Feb 1, 2007
    #5
  6. Roland Hall Guest

    "Anthony Jones" <> wrote in message
    news:...
    >
    > "Evertjan." <> wrote in message
    > news:Xns98CAA4C8FE883eejj99@194.109.133.242...
    >> wrote on 01 feb 2007 in
    >> microsoft.public.inetserver.asp.general:
    >>
    >> > here is my code
    >> > logon is set to 1 in a include that is only on member pages
    >> >
    >> > <%if logon<>1 then

    >>
    >>
    >> > if session("user_ID") <> 0 OR Session("user_ID") <> "" then

    >>
    >> This boolean is always true!!!!
    >>
    >> The boolean can only be false,
    >> if session("user_ID") is both 0 and "" at the same time,
    >> which is impossible.
    >>

    >
    > Are you sure? What if Session("User_ID") is empty?
    >
    > This code would be better:-
    >
    > If Session("User_ID") = Empty Then


    -A starter template-

    ' loggedin.asp - included in members only pages
    <%
    dim username
    username = session("username")
    if username = "" then Response.Redirect "login.asp"
    %>

    ' common.asp
    <%
    sub prt(str)
    Response.Write str & vbCrLf
    end sub

    sub lprt(str)
    Response.Write str & "<br />" & vbCrLf
    end sub
    %>

    ' login.asp
    <%@ Language="VBScript" %>
    <%
    Option Explicit
    Response.Buffer = True
    %>
    <!--#include file="common.asp"-->
    <%
    dim method
    method = Request.ServerVariables(""Request_Method")
    if method = "POST" then
    ' process login
    ' ...
    ' if login successful
    session("username") = rs("username")
    Response.Redirect "welcome.asp"
    else
    prt "<html>
    prt "<head>"
    prt "<title>Login</title>"
    prt "</head>"
    prt "<body>"
    prt "<form action="""" method=""post"">"
    lprt "Username: <input type=""text"" name=""username"" value="""" />"
    lprt "Password: <input type=""password"" name=""password"" value="""" />"
    lprt "<input type=""submit"" value=""Login"" />"
    prt "</form>
    lprt "Not a member? <input type=""button"" value=""Register""
    onclick=""locaton.href='register.asp'"" />"
    lprt "You can also browse our site as a visitor by clicking <a
    href=""visitor.asp"">here</a>."
    lprt "You must register to have full access to the site."
    prt "</body>"
    prt "</html>"
    %>

    ' welcome.asp
    <@ Language="VBScript" %>
    <%
    Option Explicit
    Response.Buffer = True
    %>
    <!--#include file="loggedin.asp"-->
    <!--#include file="common.asp"-->
    <%
    ' code goes here
    prt "<div class=""toolbar"">Username: " & username & " <a
    href=""location.href='logout.asp'"">logout</a></div>"

    ' ...
    %>

    ' logout.asp
    <%
    session.Abandon
    Response.Redirect "login.asp"
    %>
     
    Roland Hall, Feb 2, 2007
    #6
    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:
    690
  2. Eliyahu Goldin

    Lost session variables - size issue?

    Eliyahu Goldin, Jan 13, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    384
    Chris Botha
    Jan 14, 2004
  3. =?Utf-8?B?TWljaGFlbCBTTA==?=

    RE: Lost Session Variables

    =?Utf-8?B?TWljaGFlbCBTTA==?=, Feb 25, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    456
    =?Utf-8?B?TWljaGFlbCBTTA==?=
    Feb 26, 2004
  4. P. Prosper
    Replies:
    2
    Views:
    495
    =?Utf-8?B?UGF1bCBI?=
    Aug 26, 2005
  5. Guns

    Session variables are lost

    Guns, Jul 16, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    452
    Alexander Widera
    Jul 16, 2005
Loading...

Share This Page