end a sesssion? huh... im so stuck..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lizlazloz
Forum Commoner
Posts: 64
Joined: Mon Dec 29, 2003 7:29 am

end a sesssion? huh... im so stuck..

Post by lizlazloz »

ok, i have code so that a user can only view a page once a day.

the page will only display if the session variable is not set, then it will set the variable, so ti cant be seen again, OK?

the thing is, how do i get it so at midnight the user can then view the page again that day?

then once the next day, and once the next day, and so on...
lizlazloz
Forum Commoner
Posts: 64
Joined: Mon Dec 29, 2003 7:29 am

Post by lizlazloz »

:bump:
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

You will probably have to use cookies, or some sort of database. Sessions() are only designed to be temporary, which means that as soon as the user closes the browser the session is destroyed.
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

Expanding on what Gen-ik said:
I guess you could set a cookie that automatically sets the expiration time for midnight that day? Problem with cookies is that they can be changed or possibly not even set on the client's computer.

Another way you could do it would be so that everytime a user views that page, before it is shown the database is queried to see if they have already seen it. If they are not in the database, let them see it and if they are then stop the loading of the page. Then add the user to the database if they view the page.
Post Reply