问题
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.
回答1:
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();
来源:https://stackoverflow.com/questions/6972506/how-to-use-php-sessions-with-rest-client-application