Welcome Guest, Not a member yet? Register   Sign In
SOLVED - session data available outside of CI ??? - example, for CKFinder (FCKeditor plugin)
#1

[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'])...
would work. However, I'm validating users INSIDE of my CI application and storing their logged in status with
Code:
session->set_userdata
- and I can't figure out how to pass session data OUT of CI and into the CKFinder (or any other external script).

I thought maybe I could just do
Code:
session_start();
$_SESSION['mySession'] = 1;
inside a CI function - and then be able to access that session from any other PHP script outside of CI ... but that doesn't seem to work Sad

I'm sure it is very simple to do but I can't think how!

Hope someone can help! :-)

Flemming
#2

[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.
#3

[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! Smile
#4

[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"
and then access that either inside OR outside of your CI application.

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.
#5

[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?
#6

[eluser]Flemming[/eluser]
Not at all sure! ... could anyone else comment on that?
#7

[eluser]Vince Stross[/eluser]
I figure it is possible - just haven't had a reason to try it.

Glad you found your answer though! Wink




Theme © iAndrew 2016 - Forum software by © MyBB