PHP基础知识(四)——Cookie、Session
COOKIE
1 设置cookie
setcookie(name, value, expire, path, domain, secure, httponly);
2 读取cookie
if(isset($_COOKIE('username'])) $username = $_COOKIE['username'];
3 删除cookie
setcookie('username', 'Hannah', time() - 2592000, '/');
SESSION
1 开启session
session_start();
2 设置session值
$_SESSION['username'] = 'winstar';
3 读取session值
$username = $_SESSION['username'];
4 销毁session
session_destroy();
5 设置session过期时间
ini_set('session.gc_maxlifetime', 60 * 60 * 24); //设置 echo ini_get('session.gc_maxlifetime'); //读取
相关推荐
houmenghu 2020-11-17
jincheng 2020-09-01
阳光之吻 2020-08-03
hzyuhz 2020-07-04
服务器端攻城师 2020-06-26
xuanwenchao 2020-06-14
Lophole 2020-06-13
明瞳 2020-06-08
Dreamya 2020-06-03
SoarFly00 2020-06-03
咻咻ing 2020-06-01
三动 2020-05-29
kentrl 2020-11-10
逍遥友 2020-10-26
Blueberry 2020-08-15
xclxcl 2020-08-03
zmzmmf 2020-08-03
PkJY 2020-07-08