Cookie Help

Can some one please help me achieve setting a cookie so that when a user re-visits my site it will display the date that they last visited? Please, and thank you for any help

Check out http://www.php.net/manual/en/function.setcookie.php. If you still can’t figure it out completely share the code that you do have and we’ll be able to correct it and/or make suggestions!

to add to what mdahlke has said, you should also be aware a new law came into force last year regarding cookies and the grace period ended this year. Now, ALL websites that use cookies have to inform the user and give them the option to not accept a cookie. There are some exceptions but yours would not fall into that category.

Cookie Law.

Red :wink:

Also, on top of the other good comments, I would assume that you have a log in system because you mentioned users coming to your site. Therefore, you must have a SQL or MySQL DB that keeps track of your usernames and passwords. Just add another field to that DB table and call it something like “last_vist”. Then, each time your user logs into your site, just use the DB UPDATE command to update just the current date and time to that field.

Just remember you should display the last-visited date/time BEFORE you change it. Some programmers code this upon LOG-OUT not log-in. I find that the user really doesn’t care when they logged in, so this field is just needed for the ADMIN to keep track of user’s that no longer log in or other issues. Therefore, I usually do it at log-in time.

Hope that helps!

Sponsor our Newsletter | Privacy Policy | Terms of Service