1

I change the config.php code as document says, but I can't pass session into this file.

The code in CKfinder/config.php:

<?php
    session_start();

    function CheckAuthentication(){
        if(isset($_SESSION['User']['CK_check'])){
            return true;
        }else{
            return false;
    }
    ...
?>

I created $_SESSION['User']['CK_check'] when user login.

needs some help.

Thanks a lot!

svcputl3y7
  • 33
  • 1
  • 7

1 Answers1

0

http://php.net/manual/en/session.configuration.php#ini.session.save-handler If you choose the default files handler. session save path

File: ckfinder/config.php.


    // get the session_id from codeigniter cookie.   
    $session_id = $_COOKIE['ci_session'];

    // get the session data by session_id,replace to your session save path

    $content = file_get_contents(dirname(__FILE__) . '/../../application/common/ci_session/ci_session' . $session_id);

    // Start new or resume existing session
    session_start();

    // Decodes session data from a session encoded string
    session_decode($content);

If you choose the redis handler, you can do like below:

    $session_id = $_COOKIE['ci_session'];
    // $content = file_get_contents(dirname(__FILE__) . '/../../application/common/ci_session/ci_session' . $session_id);

    $redis = new Redis();
    $redis->connect('127.0.0.1', 6379);
    $content = $redis->get('ci_session:' . $session_id);
    $redis->close();
    // session_id($session_id);
    session_start();
    session_decode($content);
chaegumi
  • 1
  • 2
  • 2
    While this code snippet may solve the question, [including an explanation](http://meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers) out of the code really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. Please try not to crowd your code with explanatory comments, this reduces the readability of both the code and the explanations! – Kyll Nov 12 '15 at 16:31
  • Thank you for your answer, but it's not work for me. – svcputl3y7 Nov 22 '15 at 14:18
  • And I don't have this path `/../../application/common/ci_session/ci_session`. – svcputl3y7 Nov 22 '15 at 14:21
  • @shadowPaw the path is an example.you must change yourself path – chaegumi Jan 26 '16 at 10:17
  • @shadowPaw I have no idea, first i get the cookie name ci_session (the default value in codeigniter) next i get the session data by cookie and use function session_decode(like this http://php.net/manual/en/function.session-decode.php#53232) to decode the session data, Last you can normal use $_SESSION – chaegumi Jan 26 '16 at 10:19
  • I have the same question regarding passing session data to ckfinder with codeigniter and this answer doesn't help at all. Some explanation would be nice. – vertigoelectric Oct 10 '16 at 18:53
  • Here's the solution that works well for me [Codeigniter 3.x, Ion-auth, CKFinder - how to pass the logged in status from ion-auth to CKFinder's config file](https://stackoverflow.com/questions/47607255/codeigniter-3-x-ion-auth-ckfinder-how-to-pass-the-logged-in-status-from-ion?answertab=votes#tab-top), and @vertigoelectric I saw your new question, that also helps me a lot, thanks to PaulID. Thank you all. – svcputl3y7 Jun 16 '18 at 11:49