setcookie函数参数介绍
setcookie语法:
setcookie(name,value,expire,path,domain,secure)
setcookie参数:
| 参数 |
描述 |
name |
The name to set the cookie variable to and hence the name to access it with |
| value |
The value of the current cookie |
expire |
When a cookie will expire (in the form of a Unix timestamp) |
path |
The directory where the cookie will be available for use |
domain |
The domain at which the cookie will be available |
secure |
Whether a cookie can be read on a non-SSL enable |
setcookie函数实例
<?php
$GLOBALS[\'username\'] = \"test\";
$GLOBALS[\'password\'] = \"test\";
/* http://www.manongjc.com/article/1251.html */
function validatelogin ($username, $password){
if (strcmp ($username, $GLOBALS[\'username\']) == 0 && strcmp ($password, $GLOBALS[\'password\']) == 0){
setcookie (\"cookie_user\", $username, time()+60*60*24*30);
setcookie (\"cookie_pass\", md5 ($password), time()+60*60*24*30);
return true;
} else {
return false;
}
}
if (validatelogin (\"test\",\"test\")){
echo \"Successfully logged in.\";
} else {
echo \"Sorry, invalid login.\";
}
?> 继续阅读与本文标签相同的文章
-
美女机器人刚上市就售罄,除了生孩子,其他什么都能干!
2026-05-14栏目: 教程
-
互联网之光大会的黑科技,总有一款惊艳你!
2026-05-14栏目: 教程
-
微信宣布一项新举措,关系到每一个用户,网友一致力挺:干得漂亮!
2026-05-14栏目: 教程
-
微软建议企业客户卸载KB4520062累积更新
2026-05-14栏目: 教程
-
他让我国芯片研究停滞13年,还骗走11亿研发资金,现状如何?
2026-05-14栏目: 教程
