frenchie
frenchie

Reputation: 51937

how to timeout the client session in asp.net

I'm looking to include a behavior in the base page that, when the session times out (after say 20 min), makes a call back to the client, erases the session cookie, and redirects the user to a "your session has timed out" page.

Before I start coding, I was wondering if there's a functionality in the framework that already handles this.

Thanks.

Upvotes: 0

Views: 461

Answers (3)

Mert Susur
Mert Susur

Reputation: 583

Correct me if I am wrong but ASP.Net is already doing this. All you have to do just send an interval value to the client after each postback or ajax call. And with this interval you will also have to execute a timeout function that says "your session has expired" dialog as @geek mentioned below.

Upvotes: 0

santosh singh
santosh singh

Reputation: 28652

try this

<script language='javascript'>
function SessionTimeOuts()
{  
     self.setTimeout("RedirectToLogin();", 'any time period you wish to put here');
}

function RedirectToLogin()
{ 
     alert('Your session has expired.');
     window.location.href = 'login.aspx'

//any page where you want the redirection
}

</script>

<BODY onload=SessionTimeOuts()'> 

Upvotes: 1

Jason
Jason

Reputation: 89102

ASP.NET MembershipProvider should handle this for you

Upvotes: 0

Related Questions