pushkidman Posted May 8, 2014 Share Posted May 8, 2014 Hey there! I am wondering, is it possible to fetch data from PHP session, that was created in on another browser/computer? Let's say I know session_id() (it's stored in the database). I've googled a lot for that, but could not find any proper answer I've only found one solution, which said, that I had to restart session with new session_id(), but data from another computer is not in the array, when I output it. Quote Link to comment https://forums.phpfreaks.com/topic/288346-sessions-across-multiple-browserscomputers/ Share on other sites More sharing options...
requinix Posted May 8, 2014 Share Posted May 8, 2014 Calling session_id() before session_start() should do the trick. What's your code? Quote Link to comment https://forums.phpfreaks.com/topic/288346-sessions-across-multiple-browserscomputers/#findComment-1478781 Share on other sites More sharing options...
pushkidman Posted May 8, 2014 Author Share Posted May 8, 2014 (edited) if (!$User->getSessionKey()) { $User->setSessionKey(Roller::Session()->getId())->save(); } else { Roller::Session()->restart($User->getSessionKey()); } .... class Roller_Core_Session { public function init() { session_start(); global $_SESSION; if(!isset($_SESSION[$this->_sessionNamespace]) || !is_array($_SESSION[$this->_sessionNamespace])) { $_SESSION[$this->_sessionNamespace] = array(); } } public function restart($id) { session_id($id); $this->init(); } .... Edited May 8, 2014 by pushkidman Quote Link to comment https://forums.phpfreaks.com/topic/288346-sessions-across-multiple-browserscomputers/#findComment-1478782 Share on other sites More sharing options...
pushkidman Posted May 8, 2014 Author Share Posted May 8, 2014 Here's the above code. I've tried doing it this way, yet I still don't get data from another session... Quote Link to comment https://forums.phpfreaks.com/topic/288346-sessions-across-multiple-browserscomputers/#findComment-1478783 Share on other sites More sharing options...
requinix Posted May 9, 2014 Share Posted May 9, 2014 Have you checked to see if you're getting the right session ID in your browser? Quote Link to comment https://forums.phpfreaks.com/topic/288346-sessions-across-multiple-browserscomputers/#findComment-1478905 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.