Session Management in Joomla!
Well, at least it’s 1st time i wrote on joomla! a framework based PHP that very2 prety in structure and have a lot of functionality.
Some of you maybe a joomla! developer and try to get a joomla session and put in another php file.
You can’t just put session_start() and get $_SESSION data. Joomla’s default session is saved on #__session table. so you need to reset back session save handler to file (or another , as we know, default session save handler in PHP is file mean session data is saved in file). Just put this code on joomla’s Component/module/plugin than session need to exported
$temp_session = $_SESSION; // backup all session data
ini_set(“session.save_handler”,”files”); // set session saved hadler on file
$_SESSION[“user”]= “I’m user”; // data that another php file need to know
ini_set(“session.save_handler”,”user”); // put back session saved handler on database
$jd = new JSessionStorageDatabase();
$jd->register(); // set required parameters
session_start(); // restart //
$_SESSION = $temp_session; // restore last session data
of course you need to get session id that another php file must know. You can save it on cookie or pass it as parameter on new php file.
$e = session_id();
setcookie(“jsid”, $e, time()+3600,’/’);
nah .. in another php file you just need to set session_id and can start session
so you can see new session displayed there. Of course it just display session in files and session that saved in database can’t be shown