作者:丫头2502934891 | 来源:互联网 | 2023-08-05 22:32
后端开发|php教程php,session,数据库后端开发-php教程本篇文章主要介绍php结合session操作数据库的方法,感兴趣的朋友参考下,希望对大家有所帮助。支付宝免签接
后端开发|php教程
php,session,数据库
后端开发-php教程
本篇文章主要介绍php结合session操作数据库的方法,感兴趣的朋友参考下,希望对大家有所帮助。
支付宝免签接口源码,vscode配置arduino库文件,ubuntu虚拟硬盘,设置tomcat用户密码,批量 sqlite,家乡旅游网页设计目的,jsp访问数据库实例,云服务器提供商,ecshop 留言插件,blade前端框架,爬虫医疗领域,windows安装php,白城SEO,springboot定时消息,如何开发自己的模板标签,织梦dedecms多语言网站文章怎么,易语言禁止网页弹出,调查问卷网页html模板,网站后台密码错误,织梦手机网站怎样生成页面,理发店管理系统源码,笑话程序高级商业版源码lzw
具体如下:网狐游戏源码下载,vscode对js自动拼写,ubuntu 网络认证,tomcat窗口打乱码,爬虫通过COOKIEs,php 保存缩略图,南阳企业seo网络营销,虚拟物品交易商城网站源码,个人信息展示模板lzw
query("update ".self::$table." set value='$session_data', expiry='$session_expire' where session_id='$session_id'"); self::close(); } self::$is_del = TRUE; } /** * 销毁 * * */ public static function destroy() { $session_id = self::get_session_id(); $_COOKIE['WBSID'] = ''; self::open(); self::$dbo->query("delete from ".self::$table." where session_id='$session_id'"); self::close(); } /** * 读取 私有 * */ private static function read() { $session_id = self::$session_id; if (!$session_id) { $session_id = self::get_session_id(); } if (!$session_id) return array(); $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? md5($_SERVER['HTTP_USER_AGENT']) : ''; $client_ip = Fun::getIp(); $session_expire = TIME - self::get_gc_maxtime(); $rs = self::$dbo->fetchRow("select session_id, value, agent, ip from ".self::$table." where session_id='$session_id' and expiry>'$session_expire'"); if (!$rs || $rs['agent'] != $user_agent || $rs['ip'] != $client_ip) { return FALSE; } self::$session_id = $rs['session_id']; return unserialize($rs['value']); } /** * session 写入 私有 * */ private static function write(array $session_data) { $session_id = self::$session_id; if (!$session_id) { $session_id = self::get_session_id(); } $session_expire = TIME + self::get_gc_maxtime(); $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? md5($_SERVER['HTTP_USER_AGENT']) : ''; $client_ip = Fun::getIp(); $session_data = serialize($session_data); if (self::$session_id && self::$session_id === $session_id) { self::$dbo->query("update ".self::$table." set value='$session_data', expiry='$session_expire', agent='$user_agent', ip='$client_ip' where session_id='$session_id'"); } else { self::$session_id = $session_id = self::create_session_id(); self::$dbo->query("insert into ".self::$table."(session_id, value, expiry, agent, ip) values('$session_id', '$session_data', '$session_expire', '$user_agent', '$client_ip')"); } return true; } /** * session 更新 私有 * */ private static function update() { if (!self::$is_update) { $session_id = self::$session_id; $session_expire = TIME + self::get_gc_maxtime(); self::$dbo->query("update ".self::$table." set expiry='$session_expire' where session_id='$session_id'"); } self::$is_update = TRUE; } private static function close() { if (!self::$is_gc && mt_rand(1, self::$gc_rate_de)%self::$gc_rate_co == 0) { self::gc(); } self::$is_gc = TRUE; } /** * 过期session 清除 随机触发 * */ private static function gc() { $session_expire = TIME - self::get_gc_maxtime(); self::$dbo->query("delete from ".self::$table." where expiry<&#039;$session_expire&#039;"); } private static function get_session_id() { if (isset($_COOKIE[&#039;WBSID&#039;]) && strlen($_COOKIE[&#039;WBSID&#039;])==32) { $sid = $_COOKIE[&#039;WBSID&#039;]; setCOOKIE(&#039;WBSID&#039;, $sid, TIME + self::get_gc_maxtime(), self::$path, self::$domain, self::$secure, self::$httponly); return $sid; } return null; } private static function create_session_id() { $sid = self::get_session_id(); if (!$sid) { $sid = Fun::getIp() . TIME . microtime(TRUE) . mt_rand(mt_rand(0, 100), mt_rand(100000, 90000000)); $sid = md5(self::$pre_key . $sid); setCOOKIE(&#039;WBSID&#039;, substr($sid, 0, 32), TIME + self::get_gc_maxtime(), self::$path, self::$domain, self::$secure, self::$httponly); } return $sid; } public static function get_gc_maxtime() { return self::$gc_max_time; }}
总结:
flash 网站 源码,vscode手机预览,ubuntu安装exe驱动文件,tomcat发布流程,sqlite限制最大容量,pagination插件,前端框架教程视频学习,诗词名句网爬虫,php 相等,单页seo赚钱,企业网站pc 手机三合一,jq 网页加载进度条,php商城网站模板下载,网赚源码单页面,文章管理系统手机版,php网页群聊程序源码lzw