hi,
can i change the sessions for a website by my own on my conditions , like if i wanna close the session if the user haven't done any work for a specified time and keeps reopening the sessions for active users ?

In the global.asax file there is a session_end function which is called when the timeout period for the website is reached. You can use that to alter any session variables or to clear them out completely if a user has been inactive.

I believe the default timeout for session is 20 minutes, but you can modify that in your web.config if you need to specify a different time span. Also, a note on hericles suggestion, the session_end event is available when using InProc session storage. This is the default option so unless you've specified a different type of session storage, such as state server or sql server, this is what you're using.

thanks for replying but may I ask how to know if a user still active and opens the session if he is and close it if he is not , does property IsOnline works in this case ?

The ASP.NET Membership service supports this feature. To get the particular user's last activity date, use LastActivityDate property and to indicate whether the user is online or not use IsOnline property.

You can only use the property to check user is online or not. If user performs an action then you can check his status and do actions accordingly.

ok i will use Membershop service , thanks for replying.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.