But this I understand what you write. If I write in the box Username.text = "User ID" and then login with the username "programercek" I would like to visit the following web pages to automatically display "programercek" and not "User ID".
This needs to be saved, or otherwise the system works?
programercek
Participant
1510 Points
2244 Posts
Session Username
Jun 04, 2010 09:40 PM|LINK
Hi,
Using Membership. How that when you first login Save user name?
Thanks.
yashwanthb
Participant
1204 Points
207 Posts
Re: Session Username
Jun 05, 2010 04:09 AM|LINK
Following code is used for storing a value to session
<div id="premain0" style="width: 100%; cursor: pointer;"></div>
Now, let see how we can retrieve values from Session
<div id="premain1" style="width: 100%; cursor: pointer;"></div>
Yashwanth kumar Biddareddy.
Please remember to mark the replies as answers if it helps you
Yawer Iqbal
Participant
1199 Points
248 Posts
Re: Session Username
Jun 05, 2010 04:29 AM|LINK
hi programercek,
You will have user name in textbox. When you will have done authentication at that time you can save user name in session.
like explined by yashwanthb as well.
lets say you have textbox txtUserName in which you will have value.
Session["UserName"]=textUserName.text;
Now UserName will in unique session and accessable in all pages.
Hope it helped.
Please mark the replay as answer if it helped you.
nareshguree2...
Star
11118 Points
1997 Posts
Re: Session Username
Jun 05, 2010 06:30 AM|LINK
when successfully login
store username in session
Session["UserName"]= txtUserName.Text;
and how to user
if(Session["UserName"]!=null)
{
//do what you want
}
else
{
Response.Redirect("login.aspx",false);
}
happy coding
hans_v
All-Star
35986 Points
6550 Posts
Re: Session Username
Jun 05, 2010 10:18 AM|LINK
You don't have to save anything! When someone is still logged in, the Username can always be retrieved with:
user.identity.name
http://msdn.microsoft.com/en-us/library/system.web.httpcontext.user.aspx
programercek
Participant
1510 Points
2244 Posts
Re: Session Username
Jun 05, 2010 04:45 PM|LINK
Hi,
Thanks for your help.
But this I understand what you write.
If I write in the box Username.text = "User ID" and then login with the username "programercek" I would like to visit the following web pages to automatically display "programercek" and not "User ID".
This needs to be saved, or otherwise the system works?