應用的方便性做了大概的了解。
session的意義大家都應該清楚,一個session可以包括數次http的請求和應答,
比如我們用163.net,從login到logout或 " /> 性8sex亚洲区入口,国产精品久久久久久久久久,国产探花在线精品

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

php4的session功能評述(一)

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 <? echo $count; ?> times.<p>  
# the <?=SID?> is necessary to preserve the session id
# in the case that the user has disabled cookies

To continue, <A HREF="nextpage.php?<?=SID?>">click here</A>

session_register可以隱式地激發session_start(如果用戶之前沒發session_
start調用),當前的session注冊了一個變量count,每次用戶點擊click here
的時候,這個變量都會增一。你可以自己試一下。<?=SID?>的意義不多贅述。  

php技術php4的session功能評述(一),轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 淮北市| 平阳县| 五常市| 万盛区| 湘潭市| 岳阳市| 龙陵县| 高淳县| 彝良县| 青川县| 平定县| 朔州市| 临洮县| 凤庆县| 武宁县| 上虞市| 嘉义市| 洪泽县| 和静县| 杭州市| 商南县| 普陀区| 噶尔县| 木里| 赞皇县| 万宁市| 萨迦县| 北京市| 基隆市| 博野县| 台东市| 香港| 遂平县| 安吉县| 呼和浩特市| 武平县| 观塘区| 墨脱县| 攀枝花市| 阜宁县| 温泉县|