In php, is it possible to call and display the date and time a cookie was set?

  • Thread starter Thread starter Hullabaloo
  • Start date Start date
H

Hullabaloo

Guest
I have a form that I have created using php. I have set a cookie that disallows more than one post per person within a 24 hour period. It they try to resubmit another post in that time frame they get an error message that displays to the effect of "You already submitted a request with the name of Subject on date/time." I am using a variable to fill in the $subject, and that works fine, but I need to know if there is a way to call the date and time a cookie was set into the message? If not, is there any other way to accomplish this?

Mike
Okay, let me clarify for those that say the approach is wrong. I know - I would not do it this way; however, this is an assignment and we are required to do it this way. Basically, just to see if we can set and use a cookie (which I can do that fine). I just need to know how to call the date and time into a message.
 
basically, the purpose of a cookie is to keep track of some information on a client. Its usually created the first time they enter the site. At this time, you can save the current date and time in the cookie variable.


$_COOKIE['firstVisitDate'] = php_date();//whatever the php syntax is

and every time the clients visits the site you retrieve the cookie, and check the fields you initially created.
 
Your approach is wrong. Any idiot can clear his cache and thus defeat your efforts. Anyone with half a brain in his head is going to figure that out inside of 10 seconds.

A stronger way to accomplish what you want is to record the IP address of the user and store the time of his vote in a MySQL database. Or, better yet, tie voting to a membership account that requires a login and valid e-mail address.

http://phpeasystep.com/workshopview.php?id=6
 
basically, the purpose of a cookie is to keep track of some information on a client. Its usually created the first time they enter the site. At this time, you can save the current date and time in the cookie variable.


$_COOKIE['firstVisitDate'] = php_date();//whatever the php syntax is

and every time the clients visits the site you retrieve the cookie, and check the fields you initially created.
 
Back
Top