Monday, March 26, 2012

Session variable problem

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 S
ession 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 s
hould I do to avoid this problem?
Thanks,
Alex Fimine
alex@dotnet.itags.org.agfconsulting.com> 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" <AlexFimine@.discussions.microsoft.com> wrote in message
news:926DE728-127C-47D5-ADBD-F517C726D2A2@.microsoft.com...
> 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
> alex@.agfconsulting.com
Kevin, I know that according to the code the session is created BEFORE - tha
t, not surprisingly, was my intention. However, as I explained, there is a p
roblem with that.
"Kevin Spencer" wrote:

> According to your code, the Session variable is initialized BEFORE userpag
e
> opens:
>
> ""User"");</script>")
> --
> HTH,
> Kevin Spencer
> ..Net Developer
> Microsoft MVP
> Big things are made up
> of lots of little things.
> "Alex Fimine" <AlexFimine@.discussions.microsoft.com> wrote in message
> news:926DE728-127C-47D5-ADBD-F517C726D2A2@.microsoft.com...
> ""User"");</script>")
> Session and kicks the user out. However, when you repeat the login, the pa
ge
> sees the Session. It looks as if the session were created then the userpa
ge
> opens - can it be? What should I do to avoid this problem?
>
>

0 comments:

Post a Comment