Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,

I have just started the session varibale in my project for the logged in user.
The problem that i am getting is once i set the login id.in the session variable

C#
Session["LoginID"]=userInfo.UserName;

it is not persist on the second page.it is coming blank.
what is the resion behind this.i need that session on the another page also.

Please help me.
Thanks
Posted

1 solution

I am damn sure that somewhere your session is getting cleared. You need to go through the coding and find the place where it is getting cleared. If your session is coming null then somewhere in code only you are making it null and you forgot about that. If your session is coming empty then check for the value you are assigning to the session. Try this:
C#
if(userInfo.UserName != string.empty)
{
     Session["LoginID"]=userInfo.UserName;
}
else{
    //show error.
}



--Amit
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900