Home > DeveloperSection > Forums > Pass session from profile to new page in asp.net
Royce Roy
Royce Roy

Total Post:134

Points:938
Posted on    April-10-2015 7:20 AM

 ASP.Net ASP.Net 
Ratings:


 1 Reply(s)
 474  View(s)
Rate this:
I know how to pass session from login page to user's profile but how to pass the same session from profile to new page


Mayank Tripathi
Mayank Tripathi

Total Post:397

Points:3117
Supported
Posted on    April-10-2015 8:00 AM

By default, session variables are stored in the web server’s memory. You can receive session value from any page after creating. eg. from the login page if you redirect to any page, the code can be as follows:


protected void cmdRedirect_Click(object sender, EventArgs e)
{
    Session["UserName"] = txtUserName.Text;
    Response.Redirect("Default.aspx");
}
Reading session value from Default.aspx:
 
string LoginUser ="";
if(Session["UserName"]!=null)
    LoginUser = Session["UserName"].ToString();

Also, you can use the Membership class to get variables from the membership profile

 

Session["MySessionDataVariable"] =
Membership.GetUser().UserName


Don't want to miss updates? Please click the below button!

Follow MindStick