Automatic Session Timeout

I want a little code snippet that i can place in my sessioned pages
that will automatically time out the session after a preset time and
logs out the user even before clicking the logout link.

Thanks

Try the manual, or the [URL=“http://marketplace.sitepoint.com/categories/looking-to-hire”]marketplace.

[fphp]session_cache_expire[/fphp]

From the comments:
[I][SIZE=“3”]
"The manual probably doesn’t stress this enough:

** This has nothing to do with lifetime of a session **

Whatever you set this setting to, it won’t change how long sessions live on your server.

This only changes HTTP cache expiration time (Expires: and Cache-Control: max-age headers), which advise browser for how long it can keep pages cached in user’s cache without having to reload them from the server."[/SIZE][/I]

I guess this will do the job:

[B]"you can change the max lifetime for a session with the function ini_set().

<?php
ini_set(“session.gc_maxlifetime”, “18000”);
?>
This will set the max lifetime of the script to 5 hours. You have to use this in every script that you want to change the default lifetime for.

if you want to know the lifetime of your current script, you can use:

<?php
echo ini_get(“session.gc_maxlifetime”);
?>"[/B]

Thanks

ignore_user_abort(1);

Again, not applicable. :rolleyes:

Off Topic:

If you’re going to post in a thread, please read it.