2

I know there is already an existing question identical to this (How do I pass session to ckfinder in codeigniter 3?) but it does not help at all. There's only 1 answer and it does not work for me and very little explanation is provided.

I have a CI site in which a user can log in and edit some stuff using CKEditor. I've installed CKFinder as well, but I'm unable to pass any session data to the CKFinder config file in order to authenticate the login for security. The global $_SESSION variable just returns Array() 1 and doesn't contain any of the session data (and yes, I'm using session_start();).

Using the other post's answer as a foundation, I tried retrieving data from $_COOKIE but there didn't seem to be anything particularly useful. There is no ci_session in the cookie data. The closest thing is PHPSESSID but I couldn't get anything useful from that.

Any help would be appreciated it. I've spent too long on this project already. Thanks!

Community
  • 1
  • 1
vertigoelectric
  • 1,307
  • 4
  • 17
  • 37
  • Can you clarify which bit you are having trouble with? Accessing session data? Setting cookie data? Passing data to a view? Using data in js? – PaulD Oct 10 '16 at 22:22
  • CKfinder opens up in a new window whose source is a direct URL to `assets/ckfinder/ckfinder.html` and is therefore technically outside of the CI framework. It is initialized by a `config.php` file in the same directory. The `config.php` file has the authentication function for securing CKfinder, it is not seeing any session data that is created within the CI framework (such as the controller that loads the view that has the editor that opens CKfinder). I need to pass session data to the `config.php` file. – vertigoelectric Oct 11 '16 at 05:30

1 Answers1

3

You should not be altering a config file by writing to it for each user. Since this is a commercial application I cannot view the docs for it, but this might help.

  1. Set the link on the user page to CKfinder to only show if the user is logged in.
  2. Set the controller CKfinder links to within CI to detect if the user is logged in or not and allowed (ie authenticated and authorized), otherwise reject the request.
  3. Alternatively create a CI library for CKfinder that runs it from within CI.

Knowing CKeditor quite well, I am sure CKfinder will be documented quite well to integrate with frameworks and existing systems quite easily. CKeditor is a beautiful script (albeit with limitations) so I would presume the same quality applies to CKfinder.

And yes, CI session data is not available outside CI. Third party apps like this can be integrated with CI using standard includes directly or with a library etc within the CI framework. In fact one of the great things about CI is the ability to write small libraries that can easily include almost any third party app with relative ease of implementation.

This link will help: Codeigniter 3 - Access Session from Outside Codeigniter Installation

Without further code samples or a more exact example of the problem, I am not really sure how I can help more than that. I hope it might of been of some help but it probably was not. Sorry.

Community
  • 1
  • 1
PaulD
  • 1,161
  • 1
  • 9
  • 14
  • Unfortunately none of your 3 solutions will work for me. Is there no way to use native PHP sessions or something that will work both inside and outside the CI framework? – vertigoelectric Oct 11 '16 at 06:03
  • Of course, CI does not stop you using anything you want. However re working the entire session library just for this does not seem correct. CI uses the php $_SESSION super global so you can interrogate that at any time. – PaulD Oct 11 '16 at 06:09
  • What do you mean by "interrogate"? When I try using $_SESSION the CKfinder still does not see anything in it. – vertigoelectric Oct 11 '16 at 06:11
  • No, I am not surprised. How exactly would it know? You have not related the systems to each other in any way. Try this: http://stackoverflow.com/questions/31006756/codeigniter-3-access-session-from-outside-codeigniter-installation – PaulD Oct 11 '16 at 06:14
  • Without access to the working of CKfinder, I am just guessing. I will leave it there, sorry if it was of no help. – PaulD Oct 11 '16 at 06:16
  • That link looks like it might help. Thank you. I really appreciate your time. – vertigoelectric Oct 11 '16 at 06:33
  • Well sorry I couldn't be of more help. Good luck solving it. – PaulD Oct 11 '16 at 06:37
  • I followed the steps on the answer on the link you provided and IT WORKS! You were a tremendous help! Thank you! – vertigoelectric Oct 12 '16 at 18:37
  • :-) Glad you got it sorted. Perhaps you could mark the answer as correct. – PaulD Oct 12 '16 at 20:59
  • Yes, I was going to do that, and also maybe you could edit the answer with a focus on that link so others can find it more quickly. – vertigoelectric Oct 13 '16 at 01:46
  • Fair point and have done so. Thanks for the check mark. Even though I suppose it was not me that actually answered it for you, but the contributions to the linked answer. Anyway, good luck with your site. – PaulD Oct 13 '16 at 09:30