php4比php3新加了session的支持。稍微用了一下,对其函数接口,内部机制,
应用的方便性做了大概的了解。
session的意义大家都应该清楚,一个session可以包括数次http的请求和应答,
比如我们用163.net,从login到logout或者超时就作为一个session,session
的唯一标识一般是在系统内部生成一个唯一的session ID,一般是一个挺长的
字符串。一个session除了session ID,还可以有自己的session data,可以
记录和区分sesion的不同状态。
php4对session操作提供以下接口:
session_start — Initialize session data
session_destroy — Destroys all data registered to a session
session_name — Get and/or set the current session name
session_module_name — Get and/or set the current session module
session_save_path — Get and/or set the current session save path
session_id — Get and/or set the current session id
session_register — Register a variable with the current session
session_unregister — Unregister a variable from the current session
session_is_registered — Find out if a variable is registered in a session
session_decode — Decodes session data from a string
session_encode — Encodes the current session data as a string
意义大家一看就能明白,session_start开始一个session,session_destroy结
束一个session,session_id取得当前的session_id,session_register向当前
的session注册一个变量,这个很有用,比如用户逛商场,选中了某几样商品你
就可以用session_register把商品名称或者代码register到当前的session中。
比如下面例子(摘自php manual):
<?php
session_register("count");
$count++;
?>
Hello visitor, you have seen this page
times.
# the is necessary to preserve the session id
# in the case that the user has disabled cookies
To continue, ">click here
session_register可以隐式地激发session_start(如果用户之前没发session_
start调用),当前的session注册了一个变量count,每次用户点击click here
的时候,这个变量都会增一。你可以自己试一下。 的意义不多赘述。
相关视频
相关阅读 Windows错误代码大全 Windows错误代码查询激活windows有什么用Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Windows QQ聊天记录Windows 10自动更新怎么关闭 如何关闭Windows 10自动更新windows 10 rs4快速预览版17017下载错误问题Win10秋季创意者更新16291更新了什么 win10 16291更新内容windows10秋季创意者更新时间 windows10秋季创意者更新内容kb3150513补丁更新了什么 Windows 10补丁kb3150513是什么
热门文章 没有查询到任何记录。
最新文章
PHP入门教程书籍介绍
用可牛为MM无痛纹身刺
编译apache的rewrite模块实例Apache中URL Rewrite技术实现方式在PHP中有urldecode()等函数来解决网页URL编PHP中的mb_convert_encoding转换编码与icon
人气排行 在PHP中有urldecode()等函数来解决网页URL编dede 完美分页效果! pagelist修改,实现门PHP入门教程书籍介绍用IdHTTP获取UTF-8编码的网页apache泛域名解析+泛域名指向处理文件ThinkTemplate模板引擎的设计和使用方法如何用php将任何格式视频转为flv破解防盗链图片的php函数
查看所有0条评论>>