Hello guys,
I need to know the best way to perform this work:
User will be having 75 mins time to process the order otherwise it will be canceled.
- I wish to notify user after 60 min i.e. 15 mins before that you have only few minutes left. it could be after 65 minutes ( all depends on the page request time) but one notice to be displayed before the expiry time.
thanks in advance.
Awaiting your response.
Thank you for such a quick response.
Time is independent of logging in and logging out. no matter how many time user logged in/logged out.
I am setting the start time as soon as one product is added to the cart.
You could set a JS session cookie when the user starts the order process with the local date/time.
Set a JS setTimeout() function, say every 10 mins and check the time left. Your func could unhide a DIV at the top of the screen when <15mins left.
You could then clearTimeout() and set a new event for a 5min duration and perhaps change the DIV colour a stronger colour.
Once the time is <0 destroy the session cookie.
You could then redirect the URL to perhaps a logout page etc.
Of course, you’ll need to detect if JS & cookies are enabled first
Cheerz,
Wil.
In that case your best best would be to store a server session cookie. Same principal though, just pass the PHP session counter to a JS variable on the page.
Have a look at PHP Sessions http://www.php.net/manual/en/book.session.php
I guess I’d store all this this in a DB. Only difference is that you’ll need to check the last login session time when a user loggs in and pass that back to the JS.
When checkout is done, clear the session.
You can’t rely upon a start/stop with the user logging out as they could simply quit the browser so put all the functionality on the login.
Hope this helps,
Wil.