简体   繁体   English

php:会话数据丢失

[英]php: Session data lost

I'm using php Session to store value on a server during an API call. 我正在使用php Session在API调用期间将值存储在服务器上。

The issue here is that on my local server is working fine while on live server nothing is store in the session. 这里的问题是,在我的本地服务器上工作正常,而在活动服务器上,会话中没有存储任何内容。

This is the work flow, basically I have an indipendent script calling Magento API : 这是工作流程,基本上我有一个独立的脚本,调用了Magento API:

[Script calling API ] -> [Magento Server]

On Magento side: 在Magento方面:

  1. the API is called API被称为
  2. API set some value in a session API在会话中设置一些值
  3. an observer try to read these value 观察者尝试读取这些值

The strange thing is that if I run my API call to on my local Magento server (copy of DEV), everything is fine while calling Magento DEV server, session var are empty. 奇怪的是,如果我在本地Magento服务器(DEV的副本)上运行对API的调用,则在调用Magento DEV服务器时一切都很好,会话var为空。

This is how I'm setting the session value: 这是我设置会话值的方式:

Mage::getSingleton('admin/session')->setApiQuoteId($quoteId); 

However I'm quite sure code part is ok ( as it works fine here ) my doubt are: 但是我很确定代码部分是可以的(因为它在这里可以正常工作),我的疑问是:

  1. Can I use session with out using a browser but a script/API call to access server ? 我可以不使用浏览器而是使用脚本/ API调用来访问服务器吗?
  2. Any server setting can broke the above functionality ? 任何服务器设置都可以破坏以上功能吗?

Local server: PHP - 5.4.6 本地服务器:PHP-5.4.6

Dev Server: PHP - 5.2.17 开发服务器:PHP-5.2.17

Sessions are identified by a cookie. 会话由Cookie标识。 If your api cannot hold a cookie and send it everytime, you will loose the session variables everytime because a new session will be allocated. 如果您的api无法保存cookie并每次发送,则每次都会丢失会话变量,因为将分配一个新的会话。

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

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