How session ended after 24 hours? e.g. If someone buys products, then stock of products will decrease, but they did not confirm / pay for it, so that their purchases will be canceled and stock products will increase again.
Asked
Active
Viewed 152 times
-4
-
1what have you **tried yourself** so far? – Franz Gleichmann Jan 14 '17 at 10:09
-
I just wanna know the logic, not the source code. @FranzGleichmann – user3142154 Jan 14 '17 at 10:11
-
1SO is not a service for free algorithm ideas.. but have you tried *regularly checking for aged out orders*? – Franz Gleichmann Jan 14 '17 at 10:13
2 Answers
0
To use a session in php, you can use $_SESSION
by session_start()
And after particular time period use session_destroy()
to clear. But, before this update product information which are not confirmed by user. Or you can use job scheduler like :
php cron
phpjobscheduler
0
Try to add a cron job with a script that verify the user accounts.
An example: the cron job runs every hour and call a php script that check for the dates of the user requests. If the user requested a product 24 hours ago or more and not paid for it, then the cron job script will just delete the user request and stock the product again.
Know more about cron jobs here Executing a PHP script with a CRON Job.

Community
- 1
- 1

Vincius Oliveira
- 59
- 2
- 8