Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 31, 2011 05:04 PM by sachingusain
Member
72 Points
117 Posts
Jan 30, 2011 08:42 AM|LINK
how to check session every time.
All-Star
18287 Points
2740 Posts
Jan 30, 2011 12:55 PM|LINK
Hi
You can check like:
if (Session["varName"]!=null) { //There is a session key named varName } else { //No key }
294 Points
62 Posts
Jan 31, 2011 04:54 AM|LINK
Could you please be more specifc what you want to check with respect to Session object?
Participant
872 Points
251 Posts
Jan 31, 2011 05:21 AM|LINK
for checking session, you should first assign/create a session,
eg:On the click of the login button, a session should start and is written as : Session["name"] = "username";
now you can use Session["name"] throughout the application to check whether the user's session is active or not.
if(Session["name"] = "anyTextUwant")
{}
It is recommended that you Abandon a Session once the user clicks on the Logout Button,
Hope this is what you were looking for,
:)
Jan 31, 2011 05:35 AM|LINK
If i understood your question correctly, you want to check for session availability on every page in your applicaiton.
This can be achieved by having a BasePage in your solution and all pages in website being inherited from that one.
1/ In the BasePage override OnInit method
{
//redirect user to login page.
}
2/ Configure in web.config Form Authentication to redirect page on timeout.
402 Points
113 Posts
Jan 31, 2011 05:36 AM|LINK
http://www.codeproject.com/KB/aspnet/ExploringSession.aspx#5
This may help you .....just check it....
Star
8786 Points
1702 Posts
Jan 31, 2011 05:04 PM|LINK
Look at this video for explanation on session object: http://www.asp.net/general/videos/session-level-objects
bebikash
Member
72 Points
117 Posts
session
Jan 30, 2011 08:42 AM|LINK
how to check session every time.
adeelehsan
All-Star
18287 Points
2740 Posts
Re: session
Jan 30, 2011 12:55 PM|LINK
Hi
You can check like:
if (Session["varName"]!=null) { //There is a session key named varName } else { //No key }MCPD ASP.NET 4.0 and 3.5, MCTS WSS, MOSS, SharePoint 2010, MCT
Microsoft Community Contributor Award 2011
bala.sekhar
Member
294 Points
62 Posts
Re: session
Jan 31, 2011 04:54 AM|LINK
Could you please be more specifc what you want to check with respect to Session object?
Please mark the replies as answers if they help or unmark if not.
Yasser Shaik...
Participant
872 Points
251 Posts
Re: session
Jan 31, 2011 05:21 AM|LINK
for checking session, you should first assign/create a session,
eg:On the click of the login button, a session should start and is written as : Session["name"] = "username";
now you can use Session["name"] throughout the application to check whether the user's session is active or not.
if(Session["name"] = "anyTextUwant")
{}
It is recommended that you Abandon a Session once the user clicks on the Logout Button,
Hope this is what you were looking for,
:)
bala.sekhar
Member
294 Points
62 Posts
Re: session
Jan 31, 2011 05:35 AM|LINK
If i understood your question correctly, you want to check for session availability on every page in your applicaiton.
This can be achieved by having a BasePage in your solution and all pages in website being inherited from that one.
1/ In the BasePage override OnInit method
protected override void OnInit(EventArgs e){
base.OnInit(e); if (Session["User"] == null){
//redirect user to login page.
}
}
2/ Configure in web.config Form Authentication to redirect page on timeout.
Please mark the replies as answers if they help or unmark if not.
vaibhav_shah...
Member
402 Points
113 Posts
Re: session
Jan 31, 2011 05:36 AM|LINK
http://www.codeproject.com/KB/aspnet/ExploringSession.aspx#5
This may help you .....just check it....
Click Here For More Answers
sachingusain
Star
8786 Points
1702 Posts
Re: session
Jan 31, 2011 05:04 PM|LINK
Look at this video for explanation on session object: http://www.asp.net/general/videos/session-level-objects
Thanks.