I'm studing a case that I have a RESTful backend (php-based) and a hybrid HTML+JS+PHP front-end in different subdomains:
backend.example.com <-- A RESTful API to provide some XHR requests.
*.example.com <-- Any other domains on the same server that use the same PHP Session.
A way to initiate a persistent session in PHP without the placement of a session cookie is creating your own session id and setting it using session_id() function.
Disabling session cookie storage in fact doesn't allow me to maintain session across sub domains. So I implemented a Session Manager Class, to control all my classes' lifecycle, and to allow sharing the session across subdomains:
public static function sessionStart($name, $limit, $trusttoken){
(...)
$userip = $_SERVER['REMOTE_ADDR'];
$userbrowseragent = $_SERVER['HTTP_USER_AGENT'];
$id = md5($userip . $salt . $userbrowseragent . $sessionname); //Creating unique ID
session_id($id);
session_start();
(...)
}
Is it a secure way to share sessions in the same server but using diferent subdomains?
Note
- The Sessions will be read only in server side(PHP files)
- I don't care about trusting XHR requests.
- I'm avoiding exposing session id in requests.
- It's not possible to use SSL.
I'm avoiding exposing session id in requests.How do you maintain session state without transmitting session id? Is the persistent session backend, frontend or both? – Question Overflow Oct 31 '14 at 02:01