⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠


profile picture

Sharing Codeigniter Session with KC Finder for CK Editor

Iszuddin Ismail

Iszuddin Ismail
  • profile picture
  • Member

Posted 29 April 2017 - 03:52 AM

When you use the TEXT column type, the CK Editor will appear. And you can integrate that with KC Editor quite easily. With that, you get a file manager to upload and select images for your HTML content, for the TEXT column.


Anyhow, the KC Editor works as a stand alone script and will open up your upload folder for browsing, uploads and deletes. What I want is where KC Editor only works when the user is logged in. And the user will only upload to his or his upload folder, and cannot see anybody else's. 


KC Finder document tells that you need to integrate your system's session data and dynamically modify the values in conf/config.php in KC Finder's installation.


So here's my edit of the conf/config.php. By the way, this is if you are using database session driver in Codeigniter. I haven't figured out other session driver method yet.


Let me know what you think.

$mysqli = new mysqli("localhost", "root", "", "isra");

/* check connection */
if ($mysqli->connect_errno) {
    printf("Connect failed: %s\n", $mysqli->connect_error);

$session_id = $_COOKIE['ci_session'];
$query = "SELECT data from ci_sessions where id like '$session_id' and ip_address like '$_SERVER[REMOTE_ADDR]'";
$result = $mysqli->query($query);

$ci_valid = false;
$ci_upload_url = '../blackhole';
if ($result && ($result->num_rows > 0)) {
	$row = $result->fetch_array(MYSQLI_ASSOC);
	$ci_valid = true;
	$ci_upload_url = "../media/$_SESSION[username]";
return array(


    'disabled' => !$ci_valid,
    'uploadURL' => $ci_upload_url,
    'uploadDir' => "",
    'theme' => "default",

    'types' => array(