0

I have a REST-full setup where a PHP server sends REST requests via XML to another python server. I would like to implement sessions on the python server so that after authentication, subsequent requests will not have to send authentication information.

I have implemented the python bit and tested with a web browser. It works fine. However, performing requests from a php script to the said python server seems to create a new session each time since printing out the SESSION_ID, I get new values for each request.

So my question is, how can I make the PHP(Apache) server retain state for sessions just as normal browsers do?

user1048839
  • 938
  • 3
  • 9
  • 24
  • possible duplicate of [cURL - Need to use same session cookie in different scripts](http://stackoverflow.com/questions/10271485/curl-need-to-use-same-session-cookie-in-different-scripts) – mario Oct 21 '12 at 16:32

1 Answers1

0

Reading from another question with a similar issue,

By stateless it means that the web server does not store any state about the client. That does not preclude other services that the web server talks to from maintain state about business objects, just not about the clients connection state. The clients state should not be stored on the server, but passed around to everyone that needs it. That is where the ST in REST comes from, State Transfer. You transfer the state around instead of having the server store it. This is the only way to scale to millions of users.

The load of session management is amortized across all the clients, the clients store their session state and the servers can service an order of magnitude or more clients in a stateless fashion.

The other question here

So ALL in ALL, as much as there might be 'hacks' and 'workarounds' for this problem, it seems that fundamentally, maintaining state server side between REST-full requests negates the original architectural design.

Community
  • 1
  • 1
user1048839
  • 938
  • 3
  • 9
  • 24