I recently inherited an asp.net website made up of multiple .aspx and .ascx pages and being rather new to web development and especailly asp.net. I have the site create a cookie upon login to automatically log users back in if the page times out on them while they're entering information.
I need the site to automatically log users out when the site is closed. Obviously using the me.close event on each page won't work because we don't want it to log people out every time they navigate to a new page in the site.
I've tried setting the timeouts in both IIS and in the files of the website to longer but it doesn't seem to have an effect.
Is there an easy way to automatically log users out when they leave the site but not when they navigat开发者_运维技巧e from page to page.
HTTP is a stateless protocol, so there really is no easy way to do this.
If it's going to be an essential part of your service, you can use AJAX pings every 30 seconds, then if there isn't a ping for 2 minutes you can log them out.
This is what I've done on one of my sites apps and it seems to work quite well.
精彩评论