Forum Moderators: DixonJones
Therefore, I need to set the cookie when they leave the site... not before. If the cookie is set when they first arrive, it will show them content based on the current time, which is not what I want. I want to be able to read the cookie and use the time and date to display content during their entire visit. Then when they exit the site, the time and date will be written again for later use when they return.
I had thought of setting the cookie using Javascript's onUnload event, but I'm trying to stick to setting and reading the cookies using Perl's CGI.pm module. I had thought of doing an onUnload and calling a URL to my perl script that would set the cookie, but that isn't working out very well.
I guess I'm looking for alternative solutions that I haven't considered yet. Maybe I could set more than one cookie? I don't know. Any input would be welcome.
For example... a user comes to my site and looks at page #1. The page opens and calls the cookie info to determine what page content gets displayed. The user clicks on page #2 and the cookie is read again and uses the date to determine what content is displayed.
If I write the cookie with a new date when they arrive at page #1.... when the user visits page #2 (and subsequent pages) will not show the new content, since no new content has been added in the few minutes (or seconds) since the cookie was last written.
See what I mean?
The only way you would miss someone is if they come on day 1 at any time and then leave, and come back on day 2 early in the morning. You could solve this with a 3rd cookie but seems way more trouble than its worth to me. The above should cover 99% of the conditions.