PASS SESSION FROM PROFILE TO NEW PAGE IN ASP.NET

Royce Roy

Total Post:149

Points:1043
Posted by  Royce Roy
 758  View(s)
Ratings:
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
  1. Mayank Tripathi

    Post:397

    Points:3117
    Re: Pass session from profile to new page in asp.net

    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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!