Mr Coder
Mr Coder

Reputation: 8186

How to use PHP sessions with REST client application ?

PHP use browser cookie PHPSESSID to store the session value let say 12345 and it does by creating a file for each session on server by default (session_12345.txt ) . What if the request is coming from not a browser e.g mobile cell application accessing through REST protocol . If my rest client is sending a unique value to identify it self let say 12345 then is there anyway I can tell PHP to use this value to create session_12345.txt as if this value was coming from cookie PHPSESSID ?

Thanks in advance.

Upvotes: 2

Views: 2648

Answers (1)

NSSec
NSSec

Reputation: 4561

If you have your session ID coming in from a different source than the expected session cookie PHPSESSID, you can use the session_id() method to set the session ID yourself:

$other_value = '12345';
session_id($other_value);
session_start();

Upvotes: 4

Related Questions