How to create sessions [Resolved]

Posted by Santoshlogic under ASP.NET on 1/30/2013 | Points: 10 | Views : 952 | Status : [Member] | Replies : 7
Hello friends ...., i want to create session for each user how can i do this...?




Responses

Posted by: Ranjeet_8 on: 1/30/2013 [Member] [MVP] Gold | Points: 50

Up
0
Down

Resolved
Try this,

Session["UserID"] = TextBox1.Text; // or assign it from dataset/datatable

get value from session.

string UserID = string.Empty;
if (Session["UserID"] != null)
{
UserID = Session["UserID"].ToString();
}


Please Mark As Answer if this helps you

.

Santoshlogic, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: San.Pblr.Gct on: 1/30/2013 [Member] Starter | Points: 25

Up
0
Down
By default session is applicable for each user. you dont have to do anything to make for each user

you can say Session["Value"]=something

If there are 30 users and 30 users will have each session variable now.

Santoshlogic, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ankitsrist on: 1/30/2013 [Member] Starter | Points: 25

Up
0
Down
read my code in this same website....but one thing session automaticaly get create for each user u dont want to do some extra effort for it..http://www.dotnetfunda.com/codes/code3971-how-to-use-session-in-aspnet.aspx

Santoshlogic, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Santoshlogic on: 1/30/2013 [Member] Starter | Points: 25

Up
0
Down
Thank u Ranjeet..

Santoshlogic, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shanky11 on: 1/30/2013 [Member] Starter | Points: 25

Up
0
Down
session["shankar"] =textbox1.text;
it will assign value of textbox to shankar i.e session


another page take a label
label.text=session["shankar"].tostring();

Santoshlogic, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 1/30/2013 [Member] [MVP] Gold | Points: 25

Up
0
Down
Hi Santoshlogic

Please Mark As Answer if this helps you

.

Santoshlogic, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Santoshlogic on: 1/30/2013 [Member] Starter | Points: 25

Up
0
Down
Thank u Ranjeet for Quick responce..... i hope you wil touch with my post in future also... thanks again

Santoshlogic, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response