ref.session.php
来源:互联网 发布:mac怎么调节声音大小 编辑:程序博客网 时间:2024/05/29 03:20
SESSION函数的详细介绍
session_abort — Discard session array changes and finish sessionsession_cache_expire — 返回当前缓存的到期时间session_cache_limiter — 读取/设置缓存限制器session_commit — session_write_close 的别名session_decode — 解码会话数据session_destroy — 销毁一个会话中的全部数据session_encode — 将当前会话数据编码为一个字符串session_get_cookie_params — 获取会话 cookie 参数session_id — 获取/设置当前会话 IDsession_is_registered — 检查变量是否在会话中已经注册session_module_name — 获取/设置会话模块名称session_name — 读取/设置会话名称session_regenerate_id — 使用新生成的会话 ID 更新现有会话 IDsession_register_shutdown — 关闭会话session_register — Register one or more global variables with the current sessionsession_reset — Re-initialize session array with original valuessession_save_path — 读取/设置当前会话的保存路径session_set_cookie_params — 设置会话 cookie 参数session_set_save_handler — 设置用户自定义会话存储函数session_start — 启动新会话或者重用现有会话session_status — Returns the current session statussession_unregister — Unregister a global variable from the current sessionsession_unset — Free all session variablessession_write_close — Write session data and end session
a example of php session
simple session test <?php /* [EDIT by danbrown AT php DOT net: The author of this note named this file tmp.php in his/her tests. If you save it as a different name, simply update the links at the bottom to reflect the change.] */ session_start(); $sessPath = ini_get('session.save_path'); $sessCookie = ini_get('session.cookie_path'); $sessName = ini_get('session.name'); $sessVar = 'foo'; echo '<br>sessPath: ' . $sessPath; echo '<br>sessCookie: ' . $sessCookie; echo '<hr>'; if( !isset( $_GET['p'] ) ){ // instantiate new session var $_SESSION[$sessVar] = 'hello world'; }else{ if( $_GET['p'] == 1 ){ // printing session value and global cookie PHPSESSID echo $sessVar . ': '; if( isset( $_SESSION[$sessVar] ) ){ echo $_SESSION[$sessVar]; }else{ echo '[not exists]'; } echo '<br>' . $sessName . ': '; if( isset( $_COOKIE[$sessName] ) ){ echo $_COOKIE[$sessName]; }else{ if( isset( $_REQUEST[$sessName] ) ){ echo $_REQUEST[$sessName]; }else{ if( isset( $_SERVER['HTTP_COOKIE'] ) ){ echo $_SERVER['HTTP_COOKIE']; }else{ echo 'problem, check your PHP settings'; } } } }else{ // destroy session by unset() function unset( $_SESSION[$sessVar] ); // check if was destroyed if( !isset( $_SESSION[$sessVar] ) ){ echo '<br>'; echo $sessName . ' was "unseted"'; }else{ echo '<br>'; echo $sessName . ' was not "unseted"'; } } } ?> <hr> <a href=tmp.php?p=1>test 1 (printing session value)</a> <br> <a href=tmp.php?p=2>test 2 (kill session)</a>/*----------------------------------------------华丽分割线----------------------*/<?phpfunction getSessionData ($session_name = 'PHPSESSID', $session_save_handler = 'files') { $session_data = array(); # did we get told what the old session id was? we can't continue it without that info if (array_key_exists($session_name, $_COOKIE)) { # save current session id $session_id = $_COOKIE[$session_name]; $old_session_id = session_id(); # write and close current session session_write_close(); # grab old save handler, and switch to files $old_session_save_handler = ini_get('session.save_handler'); ini_set('session.save_handler', $session_save_handler); # now we can switch the session over, capturing the old session name $old_session_name = session_name($session_name); session_id($session_id); session_start(); # get the desired session data $session_data = $_SESSION; # close this session, switch back to the original handler, then restart the old session session_write_close(); ini_set('session.save_handler', $old_session_save_handler); session_name($old_session_name); session_id($old_session_id); session_start(); } # now return the data we just retrieved return $session_data;}?>
0 0
- ref.session.php
- php session
- php session
- PHP Session
- PHP Session
- php session
- PHP session
- PHP session
- PHP Session
- PHP SESSION
- PHP----Session
- PHP SESSION
- session php
- php session
- session php
- php session
- php session
- php session
- BFS
- Unity3D 内存 释放
- jQuery源码分析之init方法
- cocos2dx Material System讲解二
- Hadoop 设置任务执行的队列以及优先级和其他 配置
- ref.session.php
- Dynamics CRM 插件Plugin中获取和更新时间字段值的准确转换
- Hive HBase集成
- Linux下Hadoop2.6的安装
- opencv-第六章-图像变换-重映射、仿射变换、透视变换
- 深度优先搜索与广度优先搜索
- Struts的标签--实例
- Android 属性动画Interpolator和ViewPropertyAnimator的用法
- DFS