问题描述
我要建立自己的系统的计算机安全项目的一部分,而无需使用PHP的会话(只是饼干)和IM刚刚失去了.香港专业教育学院发现的所有教程都使用会话(有充分的理由),所以我想知道是否有人知道您自己的php用户身份验证教程.
I need to build my own system for part of a computer security project without using php sessions (just cookies) and im just lost. All the tutorials ive found use sessions (for good reason) so I was wondering if anyone knew of a roll your own php user authentication tutorial.
推荐答案
您基本上可以实现像您这样的会话.
You could basically implement something session like yourself.
这将包括以下任务:
- 为新用户生成一个随机会话ID(或在登录时-根据确切使用情况...)
- 将其保存到cookie
- 将其他会话信息与会话ID(例如在数据库表中)一起保存在服务器上的某处
- 在随后的页面访问中,检查cookie中的会话ID和网络服务器上的数据,以识别用户并授予访问权限
但是应该提到的是,基于cookie的解决方案从来没有那么好.例如,如果一个客户端没有启用cookie,那么它将根本无法使用.一个可能的解决方案是,如果未启用cookie,则将会话ID作为GET参数与每个内部链接一起发送.
However it should be mentioned that a cookie only based solution is never that good. If a client for example doesn't have cookies enabled it won't work at all. A possible solution for this is to send the session id as GET parameter with every internal link if cookies are not enabled.
这篇关于没有会话的PHP用户身份验证教程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!