1,105,334 Community Members

Help with Session Variable after Longin

Member Avatar
rdeveloper1
Newbie Poster
2 posts since Aug 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi! I have building an application that requires a user login. The user name and password are stored in a database table. On login, I call a stored procedure that confirms the user name and password and then directs the user to the MyAccounts page. The problem is, I am new to session states and passing session variables. How do I pass the username and information to the my accounts page and keep the session open until the user closes the application or logs out?

Any help is appreciated. Thanks!

Member Avatar
JorgeM
IT Addict
6,413 posts since Dec 2011
Reputation Points: 581 [?]
Q&As Helped to Solve: 963 [?]
Skill Endorsements: 172 [?]
Moderator
Featured
Sponsor
 
2
 

All you need to do is establish the session variable then assign th value to this variable. The session variable can be accessible until the user closes the browser or after 20 min of inactivity (default, but configurable). MSDN (Microsoft) has a really good article on this with examples.

ASP.NET Session State Overview

Member Avatar
ggamble
Junior Poster
151 posts since Mar 2006
Reputation Points: 1 [?]
Q&As Helped to Solve: 17 [?]
Skill Endorsements: 4 [?]
 
0
 

Create a User class, and add it to a Session.

Session["User"] = Users.GetUser(1);
Then you can grab the Session["User"] to fill any info you need.

Users usr = (Users)Session["User"];

string pass = usr.Password;
string usrName = usr.UserName;

Member Avatar
geniusvishal
Junior Poster
183 posts since Jan 2012
Reputation Points: -1 [?]
Q&As Helped to Solve: 17 [?]
Skill Endorsements: 3 [?]
 
0
 
Question Answered as of 7 Months Ago by ggamble, JorgeM and geniusvishal
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article