When u authenticate a user using login form,then store its name in the session.
Once the session started,u can retrieve its value anywhere until it closes.
<table >
<tr>
<td>
Email Address</td>
</tr>
<tr>
<td>
<asp:TextBox ID="textemail" runat="server" Width="300px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
Password</td>
</tr>
<tr>
<td>
<asp:TextBox ID="textpass" runat="server" Width="300px"
TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
<asp:Button ID="buttonlogin" runat="server" Text="Login"
onclick="buttonlogin_Click" />
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
class page
{
SqlConnection con;
SqlCommand cmd;
SqlDataReader dr;
protected void Page_Load()
{
con = new SqlConnection("data source=servername;initial catalog=databasename;integrated security=true");
con.Open();
}
protected void buttonlogin_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
cmd = new SqlCommand("select email,password from login where email=@email and
password=@password" , con);
cmd.Parameters.AddWithValues("@email",textemail.Text);
cmd.Parameters.AddWithValues("@email",textpass.Text);
dr = cmd.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
Session["name"]=dr.GetString(0);
Response.Redirect("userprofile.aspx");
}
dr.Close();
}
}
}
}
and when you redirected to the new userprofile page.Add a label on that page and write this code at page_load
label1.text=Session[name].ToString();
OKK