session variables don't persist ,why?

R

Raed Sawalha

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!
 
H

Hermit Dave

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top