Home  >  Article  >  Backend Development  >  大家写login.php一般用cookie还是用session?该如何解决

大家写login.php一般用cookie还是用session?该如何解决

WBOY
WBOYOriginal
2016-06-13 13:52:09636browse

大家写login.php一般用cookie还是用session?
不知道选哪个好一些。
大家都用什么能不能告诉我呢?

------解决方案--------------------
SESSION
------解决方案--------------------
SESSION安全,对服务器压力大。
------解决方案--------------------
session好一些!!!
------解决方案--------------------
重要的信息用session,比如登录信息等
服务器段运行,会话状态期间占用内存。结束后关闭则内存释放。
由于此类信息量较少,而且出于安全考虑一般用session来实现。


非重要信息用cookie


------解决方案--------------------
session
------解决方案--------------------
session好,COOKIE主要用在客户端,不好,危险.
------解决方案--------------------
session吧 不是太热的网站的话
不会怎么体现对服务器的压力的
------解决方案--------------------
俺混合用
用cookie控制刷session的时间,既保证了安全,又不对服务器造成压力
------解决方案--------------------
偶用session,不用cookie.

------解决方案--------------------
可以用cookie模拟session,采用某种方法加密数据
$chkcode = md5($row[ 'id '].$row[ 'username '].$activetime.$[ 'auth_code ']);
setcookie( "member_id ", $row[ 'id '], null, "/ ", null);
setcookie( "username ", $row[ 'username '], null, "/ ", null);
setcookie( "activetime ", $activetime, null, "/ ", null);
setcookie( "chkcode ", $chkcode, null, "/ ", null);
------解决方案--------------------
SESSION是COOKIE的一种应用而已 不能等同对比

中小站直接用SESSION比较方便 大站、多站等比较复杂的还是COOKIE比较好
------解决方案--------------------
"SESSION是COOKIE的一种应用而已 不能等同对比 "

对于session来说,保存客户端id的方法有3种,1.cookie 2.url 3.hidden field
cookie是session的一种容器之一而已。
对比的话,session的安全性较高,因为它保存在服务器端。
cookie如果要达到较高的安全性,显然要对数据进行加密/解密。
session保存的数据量较大,当然这也需要耗费服务器端的资源,而cookie最大保存数据大小是4Kb。
------解决方案--------------------
偶用session

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn