By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,152 Members | 1,837 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,152 IT Pros & Developers. It's quick & easy.

session variables don't persist ,why?

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.