Session variable time-out [Resolved]

Posted by Akiii under ASP.NET on 7/2/2011 | Points: 10 | Views : 8593 | Status : [Member] | Replies : 7
Hi all,
Can we set the session variable expiry time to unlimited ?
If yes then how to do it ?

Thanks and Regards
Akiii




Responses

Posted by: Nithadeepak on: 7/3/2011 [Member] Bronze | Points: 50

Up
0
Down

Resolved


http://msdn.microsoft.com/en-us/library/ms972429.aspx

The settings below are used to configure ASP.NET session state. .

* Mode. The mode setting supports three options: inproc, sqlserver, and stateserver. As stated earlier, ASP.NET supports two modes: in process and out of process. There are also two options for out-of-process state management: memory based (stateserver), and SQL Server based (sqlserver). We'll discuss implementing these options shortly.
* Cookieless. The cookieless option for ASP.NET is configured with this simple Boolean setting.
* Timeout. This option controls the length of time a session is considered valid. The session timeout is a sliding value; on each request the timeout period is set to the current time plus the timeout value

(If we set -1, current time plus -1 is a past time that will never reached. So the session will never expires.)(These are only my thoughts. Pls correct me if I'm wrong)

* Sqlconnectionstring. The sqlconnectionstring identifies the database connection string that names the database used for mode sqlserver.
* Server. In the out-of-process mode stateserver, it names the server that is running the required Windows NT service: ASPState.
* Port. The port setting, which accompanies the server setting, identifies the port number that corresponds to the server setting for mode stateserver.


http://msdn.microsoft.com/en-us/library/ms178194.aspx

Deleting Cookies

Deleting a cookie-physically removing it from the user's hard disk-is a variation on modifying it. You cannot directly remove a cookie because the cookie is on the user's computer. However, you can have the browser delete the cookie for you. The technique is to create a new cookie with the same name as the cookie to be deleted, but to set the cookie's expiration to a date earlier than today. When the browser checks the cookie's expiration, the browser will discard the now-outdated cookie. The following code example shows one way to delete all the cookies available to the application:

HttpCookie aCookie;

string cookieName;
int limit = Request.Cookies.Count;
for (int i=0; i<limit; i++)
{
cookieName = Request.Cookies[i].Name;
aCookie = new HttpCookie(cookieName);
aCookie.Expires = DateTime.Now.AddDays(-1);
Response.Cookies.Add(aCookie);
}


Please correct me if I'm wrong

Nitha Deepak

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

Posted by: Vforvijay on: 7/2/2011 [Member] Starter | Points: 25

Up
0
Down
hi..
Refer this links

http://msdn.microsoft.com/en-us/library/h6bb9cz9(vs.71).aspx

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

Posted by: Akiii on: 7/2/2011 [Member] Bronze | Points: 25

Up
0
Down
hi vijay....

thanks for refering the link.....
i already know how to set the the session timeout but i want to know if that can be made unlimited ?

Regards
Akiii

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

Posted by: Nithadeepak on: 7/2/2011 [Member] Bronze | Points: 25

Up
0
Down
You can set the time out period to -1 so that it never expires.

Nitha Deepak

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

Posted by: Akiii on: 7/2/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi nitha...

Thanks for the info.......!
Just tell me one thing, in cookies if we specify -1 then it will delete the cookie from the browser...??

Regards
Akiii

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

Posted by: Akiii on: 7/3/2011 [Member] Bronze | Points: 25

Up
0
Down
Thanks nitha for the answer......
and congratz for being a winner.........keep up the good work.

Regards
Akiii

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

Posted by: Nithadeepak on: 7/3/2011 [Member] Bronze | Points: 25

Up
0
Down
Thanks Akiiii.........


Nitha Deepak

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

Login to post response