0

I am working on an E commerce web site. We are storing most of the cart details on PHP Sessions.The problem what we are facing is when the customer coming to our website and select any item..... Once he selected the item he left the page for sometime (This will be greater than default session time) and customer is paying the amount after sometime ...What is happening is customer is paying the amount and the amount get deducted from his bank account. When he return bank to our site all the session will get unset...so the database update is not happening ...so my question is

  1. How i can solve this problem ?

  2. What are the best ways and what are the common practices other companies are following ?

Thanks in advance

Sumesh
  • 1
  • 1
  • Left the page means they are leaving the website? or going to another page? Are you saving data into the database? What is greater than default session time? Are you saying that it takes over 30 minutes to complete a single transaction? – Johnny Harlamert Dec 03 '13 at 06:35
  • They are not using our web site for a while..If they use then the session should retain i guess...Greater than default time means 1440 seconds in php.ini file..it wont take 5 min to complete the normal transaction ..but in some cases people will do the payment after 2 hrs at that time this will happen... – Sumesh Dec 03 '13 at 08:25

2 Answers2

0

Try using cookies instead of sessions. Cookies persist until the user explicitly clears them, or they expire (you set the expiration date). Sessions go away when the user closes the browser, or very quickly with time. In php, to read a cookie, use $_COOKIE. To set a cookie, use setcookie() (support an expiration date which is very high. Something like time()+(86400*365), or one year).

Matt Eskridge
  • 1,019
  • 10
  • 24
0

if you want to continue using session and still avoid this issue, there are two options

  1. Change the timeout value in your web.config

  2. assign the session variable to itself in regular interval

the second method will keep sending request to the server which will reset the time of the session expiry.

You can achieve this by calling a function using setTimeout or setInterval in jQuery

You can find more details of how to do the same easily here

Community
  • 1
  • 1
Vignesh Subramanian
  • 7,161
  • 14
  • 87
  • 150