How to use PHP sessions with REST client applicati

2019-08-03 04:03发布

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条回答
乱世女痞
2楼-- · 2019-08-03 04:37

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();
查看更多
登录 后发表回答