Reputation: 223
I'd like to allow users to set a variable through a text form, $name
for example, then I'd like to set a cookie after they fill the form, so the cookie is set to $name
.
So if in the text form, the user set $name = 'John';
Then I'd like the cookie to be set to setcookie ("name", "John")
;
Thanks!
Upvotes: 0
Views: 67
Reputation: 3165
$name = $_REQUEST['name'];
if(!isset($_COOKIE['name']))
{
setcookie('name',$name,0);//The cookie will expire at the end of the session
}
Upvotes: 0