session expire in asp.net

Posted by Vivekjj under ASP.NET on 11/1/2012 | Points: 10 | Views : 1786 | Status : [Member] | Replies : 6
Hi i have enter into some website with username and password if i not using that site in 1 min means it automatically want to logout or need to go login page . that means session expiration. how to do this




Responses

Posted by: Sourabh07 on: 11/1/2012 [Member] Starter | Points: 25

Up
0
Down
hi..

In Global.asax file of the Dot Net Application.....

do write this code in the following event.....


    void Session_Start(object sender, EventArgs e)

{
Session.Timeout = 1000;
}


Due to this, all the session variables used in the application will be expired...

Sourabh07

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

Posted by: Muhsinathk on: 11/2/2012 [Member] Bronze | Points: 25

Up
0
Down
Every web application must have a configuration file named
web.config, it is a XML-Based file, there is a section
name 'sessionState', the following is an example:

<system.web>
<compilation debug="true"/>
<authentication mode="Forms"/>
<sessionState mode="InProc" cookieless="false" timeout="1000">
</sessionState>
</system.web>

In Global.asax file we can set session timeout in Session_Start event like this

protected void Session_Start(object sender, EventArgs e)
{
Session.Timeout = 1000;
}


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

Posted by: Muhsinathk on: 11/2/2012 [Member] Bronze | Points: 25

Up
0
Down
In IIS setting you can also set default session timeout.

1) Open IIS start-->run type-->inetmgr and press enter.

2) Right Click on "Default Web Site" go to properties

3) Select Asp.Net tab, click on "Edit Configuration" Button

4) Select "State Management tab" in new popup window

In case if you are using IIS7

Select Default Web Site >> Click on Session State

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

Posted by: Muhsinathk on: 11/2/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi,
Please mark as answer if it helpful to u..That helps others who search the same..

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

Posted by: Nkkppp on: 11/4/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Vivek,

I would like to share this link so that you may not confuse between forms timeout and session timeout.

http://completedevelopment.blogspot.in/2009/12/caution-with-using-sessiontimeout-and.html

Regards,
Prathap.





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

Posted by: perfectchourasia-9163 on: 11/30/2012 [Member] Starter | Points: 25

Up
0
Down
Session.expire();

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

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

Login to post response