How to use PHP sessions with REST client application ?

僤鯓⒐⒋嵵緔 提交于 2019-12-24 12:06:37

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!