0

I'm using php Session to store value on a server during an API call.

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 :

[Script calling API ] -> [Magento Server]

On Magento side:

  1. the API is called
  2. API set some value in a session
  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.

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 ?
  2. Any server setting can broke the above functionality ?

Local server: PHP - 5.4.6

Dev Server: PHP - 5.2.17

4
  • check register_globals in server configuration and make sure it is turned off Commented Apr 15, 2013 at 20:01
  • register_globals is off on DEV server Commented Apr 15, 2013 at 20:11
  • Make sure that you have session_start(); at the top of EVERY single file that you go through (required scripts don't have to though, but there has to be a session_start(); at the top of your current user environment). Commented Apr 15, 2013 at 20:17
  • jonast92 this is not the issue Magento manage session in right way and on local it is working ( same code ) Commented Apr 15, 2013 at 20:27

1 Answer 1

1

Sessions are identified by a 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.

Sign up to request clarification or add additional context in comments.

5 Comments

are you using a browser on local?
I always use a browser to call a script file (test.php). I just change the URL to the API server inside that file(test.php), to test it on Local Magento or on DEV Magento
A browser natively supports cookies. A api call is something completely differend. Usually api's do not have the capability of retaining cookies and resending them with every request. Maybe i got the problem wrong, in which case a little more explanation would help. To answer the first question: usually api's cannot use sessions while browsers do by default (well most of them anyways).
what is strange is that on one server it is working fine on the other not ... anyway do you have an alternative approach instead of using session ?
I guess you can give it a try and check it out. But afaik there is nothing related to this area in between your dev version and test version, but i could be wrong. There are quite alot of releases in that time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.