国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

php4的session功能評述(一)

2024-05-04 23:00:34
字體:
來源:轉載
供稿:網友
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?>的意義不多贅述。  
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 青海省| 青浦区| 洪洞县| 天祝| 滨海县| 淮北市| 金山区| 乐业县| 剑阁县| 苏尼特右旗| 台前县| 建平县| 中宁县| 额敏县| 疏勒县| 海阳市| 黄梅县| 囊谦县| 无为县| 元阳县| 观塘区| 丰顺县| 锡林浩特市| 射洪县| 东海县| 梁山县| 汾阳市| 河津市| 黄陵县| 中牟县| 英吉沙县| 那曲县| 丹寨县| 宝应县| 东明县| 清水河县| 彭州市| 博客| 富源县| 新郑市| 任丘市|