This commit is contained in:
2022-06-13 23:37:17 +08:00
parent d21608a860
commit 0230cb42a2
153 changed files with 62907 additions and 0 deletions

46
includes/lib/Cookie.php Normal file
View File

@@ -0,0 +1,46 @@
<?php
namespace lib;
class Cookie{
/**
* 删除cookie
*
* @param string $name cookie名称*
* @param string $domain 域名
* @return boolean
*/
public static function del($name,$domain=null)
{
$domain = isset($domain) ? $domain : null;
return isset($_COOKIE[$name]) ? setcookie($name, '', time() - 86400, '/', $domain) : true;
}
/**
* 得到指定cookie的值
*
* @param string $name cookie名称*
*/
public static function get($name)
{
$cookies_en=isset($_COOKIE[$name]) ? (new Aes)->decrypt($_COOKIE[$name]) : null;
return trim($cookies_en);
}
/**
* 设置cookie
*
* @param string $name cookie名称*
* @param string $value cookie值*
* @param string $expire 过期时间
* @param string $path the path to website
* @param string $domain the domain
* @param string $secure 可选。规定是否通过安全的 HTTPS 连接来传输 cookie。
* @return boolean
*/
public static function set($name,$value,$expire=null,$path=null,$domain=null,$secure=null)
{
$value= (new Aes)->encrypt($value);
$path = isset($path) ? $path : '/';
$domain = isset($domain) ? $domain : null;
$secure = isset($secure) ? $secure : 0;
return setcookie($name, $value, $expire, $path, $domain, $secure);
}
}