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

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

问题描述

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

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

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

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?

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

Standard LAMP stack, running the Zend framework.

谢谢!

推荐答案

是否使用 cookie 由这些 PHP 选项配置:

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

如果设置了第一个,则将尽可能使用 cookie.
PHP 应检测 cookie 是否已启用,并仅在客户端支持时才使用它们.

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.


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


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).

但请注意,激活此选项后,PHP 将通过 GET 传递会话 ID,至少对于您网站的每个用户将访问的第一页......因为他们一开始不会有 cookie,并且检查它们是否支持 cookie 的唯一方法是设置一个,并尝试在下一页阅读它.
不支持 cookie 的用户,包括我可能会说的搜索引擎,将拥有该会话 ID——这并不好:-(

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 :-(


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


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

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

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