Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例如,我想允许用户通过文本表单设置变量$name,然后我想在他们填写表单后设置一个 cookie,因此 cookie 设置为$name.
$name
所以如果在文本表单中,用户设置$name = 'John';
$name = 'John';
然后我希望将 cookie 设置为setcookie ("name", "John");
setcookie ("name", "John")
谢谢!
以下代码
setcookie('name',$_GET['name']);
应该这样做。
$name = $_REQUEST['name']; if(!isset($_COOKIE['name'])) { setcookie('name',$name,0);//The cookie will expire at the end of the session }