简体   繁体   English

我应该依赖会话吗?

[英]Should I rely on sessions?

I am creating a social/blogging platform and I have storing their User ID in a session so I will echo the ID out of the session onto the page.我正在创建一个社交/博客平台,并将他们的用户 ID 存储在会话中,因此我会将会话中的 ID 回显到页面上。

Can a person edit the session the take an identify of another user?一个人可以编辑会话以获取另一个用户的身份吗?

这取决于设置您使用的$_SESSION变量的方法 - 检查这个相关问题以获得更多说明。

A session is just a cookie with an identifier.会话只是一个带有标识符的 cookie。

When I visit your site, you're webserver will create a session with the identifier XA7i9 for me (just an example) which my browser will store as a session cookie.当我访问您的网站时,您的网络服务器将为我创建一个标识符为 XA7i9 的会话(只是一个示例),我的浏览器会将其存储为会话 cookie。 Now, my browser is going to send XA7i9 with every request.现在,我的浏览器将随每个请求发送 XA7i9。 When you store something inside $_SESSION , it will never leave your server.当你在$_SESSION中存储一些东西时,它永远不会离开你的服务器。

However, if I tamper the session cookie and can guess your session identifier, say b8a76, your webserver might think I'm you.但是,如果我篡改了会话 cookie 并且可以猜出您的会话标识符,例如 b8a76,您的网络服务器可能会认为我是您。 It depends on your implementation.这取决于您的实施。

This question on Stackoverflow might be of interest you.Stackoverflow 上的这个问题可能会让您感兴趣。

User can't edit your session variables if you do not allow him to do so.如果您不允许他这样做,用户将无法编辑您的会话变量。

He could stole SESSID of another user他可以窃取另一个用户的 SESSID

Be aware of register_globals directive for PHP.ini注意 PHP.ini 的 register_globals 指令

A user can intercept another user's session cookie value, change their own cookie to that user's, and take over their session.用户可以拦截另一个用户的会话 cookie 值,将他们自己的 cookie 更改为该用户的,并接管他们的会话。 The only way to prevent this is to use SSL on your pages.防止这种情况的唯一方法是在您的页面上使用 SSL。 This is the same reason that Facebook enabled users to select an 'always use HTTPS' option last year.这与去年 Facebook 允许用户选择“始终使用 HTTPS”选项的原因相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM