Click to See Complete Forum and Search --> : How to respond to closing browser?


El Toro
04-10-2005, 03:09 AM
Hi All,

With my online shopping cart (based on a 'Web Thang' tutorial using Classic ASP) I use a Session Variable Array to hold the ID's of the items that a user has added to the cart. The business is a collectable records store so each item is unique and has it's own ID, so no more than one of each item can be purchased. As the user adds an item to the shopping cart the 'on hold' boolean field for that item is set to true so that it wont appear in searches by other users. If the user closes the browser before completing a sale the items are left 'on hold'.

How can I make sure I can return the status of the items to 'available' if the user closes the browser?

Any help greatly appreciated.

Regards,

El Toro

buntine
04-10-2005, 04:09 AM
This is where the global.asa file comes in handy. In it there are four functions; Session_OnStart, Session_OnEnd, Application_OnStart, and Application_OnEnd.

You will need the Session_OnEnd function, which is automatically called when a session is destroyed explicitaly by the application or by garbage collection (usually after 20 minutes of inaction, but this can be changed in IIS).

I am assuming 'on hold' is a field in the database. So, basically, you simply want to open the database and update the correct record based on the ID stored in the Session variable.

Here is an article on the Global.asa file: http://www.w3schools.com/asp/asp_globalasa.asp

Regards.

El Toro
04-10-2005, 08:13 AM
Thanks buntine,

I'll have a play with the info you suggested. For some reason I thought the Global.asa file applied only to ASP.Net and not classic ASP.

Cheers

El Toro.

buntine
04-10-2005, 08:27 AM
Your welcome. Note, ASP.NET has a Global.asax file, which has similar functionality. ;)