SOLVED - session data available outside of CI ??? - example, for CKFinder (FCKeditor plugin) |
[eluser]Flemming[/eluser]
Post detailing the solution is 3 below this one! =============================================== Hi gang, am trying to figure out how to create some session data that can be accessed by a PHP script OUTSIDE of CI. example: CKFinder (plugin for FCK editor) uses session validation to prevent unauthorised uploading of files. Normally, just something like Code: if($_SESSION['adminLoggedIn'])... Code: session->set_userdata I thought maybe I could just do Code: session_start(); ![]() I'm sure it is very simple to do but I can't think how! Hope someone can help! :-) Flemming
[eluser]louis w[/eluser]
CI session class does not use the native PHP sessions. I would do just as you suggest by setting an additional $_SESSION param. You shouldn't have to session_start anymore thou, that should be automatic.
[eluser]Flemming[/eluser]
thanks - I'll give it another try (maybe I just made a stupid typo) and post back if I get it working! ![]()
[eluser]Flemming[/eluser]
OK here's what I had to do - perhaps it'll save others a little time! It seems that by default it is not possible to use any 'native' PHP sessions in CI ... eg. not possible to set a session with Code: $_SESSION['session_name']= "value" I downloaded the Native Session Library available here: http://codeigniter.com/wiki/Native_session/ look right at the end of the post for the v1.5x version which is basically just a single file to put into system->application->libraries. Once you've put that file in you can load the library in your controllers in the normal way ($this->load->library('session'); You can still use the CI methods (eg. session->set_userdata() ) AND you can use native PHP sessions too! Now I can set session data INSIDE my CI application (eg. a login controller) and access the session data OUTSIDE of CI, through $_SESSION[] ! I know there is a tutorial on the wiki about this but hey, maybe this is useful to others and can save you a bit of frustration.
[eluser]Vince Stross[/eluser]
If you store your sessions in a database, couldn't you use a query string to pass the session id key, then read the table for anything else you might need?
[eluser]Flemming[/eluser]
Not at all sure! ... could anyone else comment on that?
[eluser]Vince Stross[/eluser]
I figure it is possible - just haven't had a reason to try it. Glad you found your answer though! ![]() |
Welcome Guest, Not a member yet? Register Sign In |