• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Ok, MySQL failed me. Anyone know cookies?

Status
Not open for further replies.

RedDwarf

Smegging smeg of a smeg!
All I need to do is make sure that people visiting a certain page can't reenter their info. Setting a cookie on the last page and checking for it on the first should work I think, as long as I set the first page to redirect them if the cookie is found. Does this make sense?

How the Hell do I program a cookie?
 
Very easy in PHP.

If you just need to save a value for the duration of one visit save the value in the session (basically a cookie that expires after they leave your website). To do this set a value in the $_SESSION hash/array, or use the session_register() function. You may need to call session_start() beforehand (depending on your config). To get at the value again, just hit up the $_SESSION hash after the session starts.

If you want to save the value in an actual cookie, over which you will have control over the expiration date, use the setcookie() function and the $_COOKIE hash.
 
Status
Not open for further replies.
Top Bottom