Session value in asp.net
In my database I have to tables with Fname,Lname,Email,One is registration and one is for creating profile.Once the user registered successfully then the the page should be redirect to the creating profile page with the data of Fname,Lname and Email.so can any one help how to write the code??for getting the data I created session and am assigning into creating profile page but some thing is going wrong so that's why am not getting data.
Rahul BansalPosted Feb 27, 2015, 12:48 AM
Session.Abondon().
Rahul BansalPosted Feb 27, 2015, 12:45 AM
session["key1"]="value1";
session["key2"]="value2";
session["key3"]="value3";
after that redirect the page to 2nd page.
Response.redirect("2ndpage.aspx");
and check all or needed sessions on page_load event of 2ndpage.aspx like
if(session["key1"]!=null && session["key2"]!=null && session["key2"]!=null)
{
//use the value of session like session["key1"].ToString()
}
else
//go to error page
Priya AvanigaddaPosted Feb 27, 2015, 12:39 AM
Khargesh RajputPosted Feb 27, 2015, 12:31 AM
can you share your code
Priya AvanigaddaPosted Feb 27, 2015, 12:27 AM
Khargesh RajputPosted Feb 27, 2015, 12:20 AM
use like
on register page
session["email"]=textemail.text;// same for fistrname and lastname if necessry
response.redirect("profile.aspx");
and on page where you want to retrieve session
if(session["email"]!=null)
{
lblemail.text=session["email"].tostring();
}
Priya AvanigaddaPosted Feb 27, 2015, 12:11 AM
Khargesh RajputPosted Feb 26, 2015, 11:52 PM
on register button after success
response.Redirect("profile.aspx?fname='"+txtfname.text+"'&lname='"+txtlname.text+"'&email='"+txtemail.tex+"'");
and on profile.aspx pageload
if(request.querystring["fname"]!=null)
{
lblfname.text=request.querystring["fname"].tostring();
//same for lname and email here
// do not use secure data such as password in querystring because querystring display in url text
}
and if you want session then on register page
session["email"]=textemail.text;
and on page where you want to retrieve session
lblemail.text=session["email"].tostring();