Session variable problem

Discussion in 'ASP .Net' started by =?Utf-8?B?QWxleCBGaW1pbmU=?=, Jul 7, 2004.

  1. Hi,

    Please help me with the following:

    In login.aspx page:

    Session("accessGranted") = 1
    Response.Write("<script>window.open(""userpage.aspx"", ""User"");</script>")


    In userpage.aspx:

    <body>
    <script language="vb" runat="server">

    Sub Page_Load(source as Object, e as EventArgs)

    if Session("accessGranted") is nothing then
    response.redirect("login_failed.htm")
    end if

    end sub

    </script>

    Problem:
    Every time a user logs in the first time the userpage.aspx doesn't see the Session and kicks the user out. However, when you repeat the login, the page sees the Session. It looks as if the session were created then the userpage opens - can it be? What should I do to avoid this problem?


    Thanks,

    Alex Fimine
     
    =?Utf-8?B?QWxleCBGaW1pbmU=?=, Jul 7, 2004
    #1
    1. Advertising

  2. > It looks as if the session were created then the userpage opens

    According to your code, the Session variable is initialized BEFORE userpage
    opens:

    > In login.aspx page:
    > Session("accessGranted") = 1
    > Response.Write("<script>window.open(""userpage.aspx"",

    ""User"");</script>")

    --
    HTH,
    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    Big things are made up
    of lots of little things.

    "Alex Fimine" <> wrote in message
    news:...
    > Hi,
    >
    > Please help me with the following:
    >
    > In login.aspx page:
    >
    > Session("accessGranted") = 1
    > Response.Write("<script>window.open(""userpage.aspx"",

    ""User"");</script>")
    >
    >
    > In userpage.aspx:
    >
    > <body>
    > <script language="vb" runat="server">
    >
    > Sub Page_Load(source as Object, e as EventArgs)
    >
    > if Session("accessGranted") is nothing then
    > response.redirect("login_failed.htm")
    > end if
    >
    > end sub
    >
    > </script>
    >
    > Problem:
    > Every time a user logs in the first time the userpage.aspx doesn't see the

    Session and kicks the user out. However, when you repeat the login, the page
    sees the Session. It looks as if the session were created then the userpage
    opens - can it be? What should I do to avoid this problem?
    >
    >
    > Thanks,
    >
    > Alex Fimine
    >
     
    Kevin Spencer, Jul 8, 2004
    #2
    1. Advertising

  3. Kevin, I know that according to the code the session is created BEFORE - that, not surprisingly, was my intention. However, as I explained, there is a problem with that.




    "Kevin Spencer" wrote:

    > > It looks as if the session were created then the userpage opens

    >
    > According to your code, the Session variable is initialized BEFORE userpage
    > opens:
    >
    > > In login.aspx page:
    > > Session("accessGranted") = 1
    > > Response.Write("<script>window.open(""userpage.aspx"",

    > ""User"");</script>")
    >
    > --
    > HTH,
    > Kevin Spencer
    > ..Net Developer
    > Microsoft MVP
    > Big things are made up
    > of lots of little things.
    >
    > "Alex Fimine" <> wrote in message
    > news:...
    > > Hi,
    > >
    > > Please help me with the following:
    > >
    > > In login.aspx page:
    > >
    > > Session("accessGranted") = 1
    > > Response.Write("<script>window.open(""userpage.aspx"",

    > ""User"");</script>")
    > >
    > >
    > > In userpage.aspx:
    > >
    > > <body>
    > > <script language="vb" runat="server">
    > >
    > > Sub Page_Load(source as Object, e as EventArgs)
    > >
    > > if Session("accessGranted") is nothing then
    > > response.redirect("login_failed.htm")
    > > end if
    > >
    > > end sub
    > >
    > > </script>
    > >
    > > Problem:
    > > Every time a user logs in the first time the userpage.aspx doesn't see the

    > Session and kicks the user out. However, when you repeat the login, the page
    > sees the Session. It looks as if the session were created then the userpage
    > opens - can it be? What should I do to avoid this problem?
    > >
    > >
    > > Thanks,
    > >
    > > Alex Fimine
    > >

    >
    >
    >
     
    =?Utf-8?B?QWxleCBGaW1pbmU=?=, Jul 8, 2004
    #3
    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. Jeff Smythe
    Replies:
    3
    Views:
    1,325
    Jeff Smythe
    Jan 2, 2004
  2. Replies:
    1
    Views:
    1,094
    Bruce Barker
    Nov 14, 2005
  3. =?Utf-8?B?Um9iSEs=?=
    Replies:
    4
    Views:
    5,415
    =?Utf-8?B?Um9iSEs=?=
    Apr 11, 2007
  4. chowchho
    Replies:
    7
    Views:
    661
    Patrice
    Mar 28, 2008
  5. Jazzis
    Replies:
    2
    Views:
    279
    Jazzis
    Sep 23, 2003
Loading...

Share This Page