如何在URL中发送PHPSESSID? [英] How can I send PHPSESSID in the URL?

查看:82
本文介绍了如何在URL中发送PHPSESSID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试通过HTTP GET变量为无cookie的客户端发送PHPSESSID.

我已经在各种drupal实现中看到了这一点,其中?PHPSESSIONID=123ABC附加到每个链接上,但是我如何在PHP中指定它,并且有什么方法可以更改GET参数,因此它可以是?token = 123ABC,或者甚至通过HTTP POST发送?

运行Zend框架的标准LAMP堆栈.

谢谢!

解决方案

通过以下PHP选项配置是否使用cookie:

如果设置了第一个,则将在可能的情况下使用cookie.
PHP应该检测cookie是否启用,并仅在客户端支持的情况下使用它们.


要启用通过GET而不是cookie传递会话ID,您可能必须激活 session.use_trans_sid ,默认情况下是禁用的(这意味着,默认情况下,会话ID仅由Cookie传递,而不会由GET传递). /p>

但是请注意,启用此选项后,PHP至少会通过GET传递会话ID到您网站的每个用户访问的第一页...因为他们最初不会使用Cookie,并且检查它们是否支持cookie的唯一方法是设置一个,然后尝试在下一页重新阅读.
不支持cookie的用户(包括我可能会说的搜索引擎)将具有该会话ID,这不是很好:-(


而且,您可能还想看看 session.name 设置密钥的名称(我的意思是设置为"token"而不是"PHPSESSID")


有关更多详细信息,请查看手册的会话处理部分:-)

I'm trying to send the PHPSESSID via a HTTP GET variable for a cookie-less client.

I've seen this in various drupal implementations where ?PHPSESSIONID=123ABC is appending to each link, but how do I specify this in PHP and is there any way of changing the GET parameter so it could be ?token=123ABC, or even sent via HTTP POST?

Standard LAMP stack, running the Zend framework.

Thanks!

解决方案

Using a cookie or not is configured by these PHP options :

If the first one is set, cookies will be used if possible.
PHP should detect if cookies are enabled or not, and use them only if they are supported by the client.


To enable passing of the session id by GET instead of cookies, you might have to activate session.use_trans_sid, which is disabled by default (Which means that, by defaut, session id is only passed by cookies -- never by GET).

But note that, with this option activated, PHP will pass the session id by GET at least for the first page each user of your site will come to... as they won't have the cookie at first, and the only way to check if they support cookies is by setting one, and trying to read it back on the next page.
And users that don't support cookies, including search engines I'd probably say, will have that session id -- and that is not nice :-(


And, you might also want to take a look at session.name to set the name of the key (set to to "token" instead of "PHPSESSID", I mean)


For more details, you can take a look at the Session Handling section of the manual :-)

这篇关于如何在URL中发送PHPSESSID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆