September 29th, 2000, 04:25 AM
I'm making an e-commerce shop and I'm using sessions.
I want a session to stop after a certain time. This is saver for the customers, because if the customer didn't log off and close the browser another person could do stuff with the customers personal things.
session.cookie_lifetime in the php.ini file can't be changed by me (I'm not the only one working on the machine).
I found the function session_set_cookie_lifetime(int lifetime, but I don't really understand how to use it.
I have application.php, in this script all the configuration is done, and also the session is set.
This script is included in all the other scipts I use.
If I put session_set_cookie_lifetime in this file it will be called each time you use it.
I thought of another way.
Making a session variable called "time". I put the current time in seconds + the time the person has in the shop in this variable.
I compare it to the current time, if the time is the same or higher the session variables will be reset.
The only problem I have with this is that it doesn't work if the logintim is 23.22 (or something like that) and the current time is 01:01 (or something like that), because 01:00 is smaller than 23:22 and it will continu until it's later than 23:22.
Well, I hope someone has a good Idea that works better than all this crap.
September 29th, 2000, 06:14 AM
why not use Unix timestamp, it increase every second.
Good Good Study
Day Day Up
September 29th, 2000, 07:20 AM
Well, I just found that sollution too (after 1 1/2 day), thanks anyway!!
I have a session variable 'time' where I store time() + time to spend in the shop.
I compare this with the current time ( time() ) when the customer loads a page.
If the time is up all the session variables are reset.