helraizer
11-19-2007, 05:50 PM
Hi all,
On my comments page, currently I have sessions to remember the username and email. This is good and works well but not from once the user closes the window. I was thinking of using cookies to save it these pieces of data instead. So that it can be loaded each time (until the cookie expires).
I know that you can use variables such as:
<?php
$variable = "my cookie value - username";
setcookie("user", $variable, time()+3600*24, "/");
?>
So that the cookie value is that of $variable and will expire in 24hours.
Is it possible to save the $_POST variables of the username and email in the cookie? So far, everything (input form and then the comments) is on one page, or would it be doable if it were on two pages? So it'd be like:
<?php
$usrnme = $_POST['username'];
setcookie("user", $usrnme, time()+3600*24, "/");
Hope that makes sense,
Thanks,
Sam
On my comments page, currently I have sessions to remember the username and email. This is good and works well but not from once the user closes the window. I was thinking of using cookies to save it these pieces of data instead. So that it can be loaded each time (until the cookie expires).
I know that you can use variables such as:
<?php
$variable = "my cookie value - username";
setcookie("user", $variable, time()+3600*24, "/");
?>
So that the cookie value is that of $variable and will expire in 24hours.
Is it possible to save the $_POST variables of the username and email in the cookie? So far, everything (input form and then the comments) is on one page, or would it be doable if it were on two pages? So it'd be like:
<?php
$usrnme = $_POST['username'];
setcookie("user", $usrnme, time()+3600*24, "/");
Hope that makes sense,
Thanks,
Sam