Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试从 twitter API 获取用户令牌。从 twitter API 重定向时,它将内容存储在会话中。我可以从会话中获取该凭据。它在本地主机上运行良好。但是在实时服务器上这样做时,我得到了一个空的 php 会话。它显示一个空数组
你检查session_start()过你的脚本吗?
session_start()
通常,您的本地 php 部署session.auto_start = 1默认具有 php.ini 设置。在生产服务器上这可能不是真的,所以session_start()如果你想确保它可以在任何地方工作,在你的脚本中明确定义是至关重要的。
session.auto_start = 1
还要检查 php.ini 设置session.use_cookies是否通过 cookie 将会话 ID 发送到用户浏览器,或者必须通过 url 查询参数手动发送,例如?PHPSESSID=....
session.use_cookies
?PHPSESSID=....