仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2245|回复: 19
打印 上一主题 下一主题

[学习教程] PHP教程之php4的session功效评述(一)

[复制链接]
因胸联盟 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-2-16 00:26:39 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
理解网站这一概念之后不难看出,任何网站都是由网页组成的,也就是说想完成网站,必须先学会做网页,因此必须要掌握了HTML,才能为今后制作网站打下基础。   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?>的意义不多赘述。  
应该大致熟悉了一些学习过程,也许我的过程和你的有些出路,但是不管怎么样是殊途同归,我写这么多,也只是给大家一个借鉴的机会,至于好与不好,默默不敢打包票^0^
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-9 18:22

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表