467,228 Members | 1,397 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,228 developers. It's quick & easy.

session variables don't persist ,why?

Hello:
My problem is that in my login page, I authenticate the user and set a
session variable:
Session("strname") = dr("userlname") & ", " & dr("userfname") & " "
& dr("usermi")
FormsAuthentication.SetAuthCookie(lngID, False)

and then redirect to another page. On that page, when I try:
Response.Write(Session("strname"))
Response.Write(Page.User.Identity.Name)

they're both empty. My web.config includes:
<authentication mode="Forms">
<forms name="P" loginUrl="intranet/login.aspx" protection="All"
path="/" />
</authentication>

The intranet/login.aspx page refers to a page on the server (not part of
this .sln) but I wouldn't think that would matter because it's
authenticating the user in the login page above.

Can anyone help?! Thanks!
Nov 18 '05 #1
  • viewed: 1341
Share:
1 Reply
session refers to current instance of user interaction with an application.

ie if you talk to applicaiton 1 you have one session
if you go to another application like you are (for authentication) its a
different / unique session for that application
since sessions are not shared between applications you dont have any access
to the variables you set earlier.
ie you jumped back to your orignal session which unforntunately dont have
those variables.

Another thing if you try to read session variables it is always advisable to
check them for null values
if not Session("strname") is null then

' read the variables here

end if
something like that..

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Raed Sawalha" <ra**********@hotmail.com> wrote in message
news:#T**************@TK2MSFTNGP10.phx.gbl...
Hello:
My problem is that in my login page, I authenticate the user and set a
session variable:
Session("strname") = dr("userlname") & ", " & dr("userfname") & " " & dr("usermi")
FormsAuthentication.SetAuthCookie(lngID, False)

and then redirect to another page. On that page, when I try:
Response.Write(Session("strname"))
Response.Write(Page.User.Identity.Name)

they're both empty. My web.config includes:
<authentication mode="Forms">
<forms name="P" loginUrl="intranet/login.aspx" protection="All" path="/" />
</authentication>

The intranet/login.aspx page refers to a page on the server (not part of
this .sln) but I wouldn't think that would matter because it's
authenticating the user in the login page above.

Can anyone help?! Thanks!

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by samtran331 | last post: by
3 posts views Thread by Mark | last post: by
1 post views Thread by Dew Baboeram | last post: by
4 posts views Thread by abcd | last post: by
26 posts views Thread by BillE | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.