How do I use PHP sessions with a REST client application?

PHP uses the PHPSESSID cookie to store the session value, let's say 12345, and it creates a file for every session on the server by default (session_12345.txt). What to do if the request is not coming from a browser, such as a cellular mobile application that uses the REST protocol. If my rest client sends a unique value to identify it, let's say 12345, can I still tell PHP to use that value to create session_12345.txt as if that value came from the PHPSESSID cookie?

Thanks in advance.

+1


source to share


1 answer


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



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

      

+4


source







All Articles