Session timeout for inactive users ?

User 2206956 Photo


Registered User
45 posts

Is there a way to install code for session timeout for inactive users ? Through either .php or .htaccess ?
I've come up with some code through Drupal (http://drupal.org/node/64413), but my head is spinning from all the code.

I've created a logout button, that seems to work fine, but I also want to timeout inactive users if they don't press the logout button and have had a period of inactivity, say 60 minutes. Is there a way to do this?
Thanks,
Jeff
User 187934 Photo


Senior Advisor
20,247 posts

http://stackoverflow.com/questions/5202 … 30-minutes
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2206956 Photo


Registered User
45 posts

Great link Rolly! Thank you. I probably have no business messing around with this kind of stuff being a non-programmer, but how else do I learn ;)

I get it that I need to create a login.php and logout.php file in the protected directory. What I don't get, is in the "Homepage.php", is the php code as shown for this homepage.php inserted into the header of my .html page ? Because it says: <!-- From here all HTML Coding can be done -->.

If I insert php code into my html page, do I have to rename my page to pagename.php ?

I tried just creating three documents called login.php, logout.php, and homepage.php and put the script in just as shown (with the local directories). It worked once or twice, but then stopped working.
User 187934 Photo


Senior Advisor
20,247 posts

I know I had that problem with a script I was working on. I had to set the set the cookie back to 0 at logout.
<?php
if(!isset($_COOKIE["ID_my_site"]))
{
header("Location: index.php");
exit;
}
?>
<?php
// set the expiration date to one hour ago
setcookie("ID_my_site", "", time()-3600);
?>
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2206956 Photo


Registered User
45 posts

Ok, where does this code go? In Logout.php, homepage.php, or login.php, or directly on my .html page?
User 187934 Photo


Senior Advisor
20,247 posts

It went at the top of my page that I redirected to when you clicked logout. It will probably have to be altered for your site but I was giving you an example.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.