I have a folder outside /application
folder of CodeIgniter called myfolder
.
My CI application uses Native PHP sessions and it all works fine. CI version is the latest 3.0-development.
I need to access some of the session data in myfolder/myfile.php. If I do a session_start()
and then print_r($_SESSION);
then I don't see the session set by CI's session driver. I understand why it doesn't show it.
Do you know any method/hack by which I can refer to session data from the CI's session in myfolder. for example by directly including, say, Codeigniter/libraries/session/drivers/session_native.php or any other file?? I just an array from the session data.
The current Session_native.php doesn't seem to change any of the built in session library's preference or interfere with how the session data is saved, i think the following should work:
- Get a hold of the session id for the session you want to load
- call
session_id($sessid)
with this session id before session_start()
- call
session_start()
This should work as long as the various ini settings that control the session lib like session.save_path
is the same and maybe (if your host have this extension installed) suhoshin settings like suhosin.session.cryptdocroot
doesn't interfere.
Its a trick but do work. Place this little naughty code just before login redirect. And now you can use ci_session
with php native session too ,have fun !
<?php
session_start();
echo $_SESSION['ci_session'] = $this->session->userdata['ci_session'];
?>
You can get in cookeis
<?php
print_r($_COOKIE['ci_session']);
Save the session data which you wants to refer from outside the folder into cookies, which may helps you.
So use cookies to refer data from outside the folder and make sure when you set cookies it should be in proper accessible path