iutbay / yii2-kcfinder

KCFinder for Yii2
21 stars 19 forks source link

share session with yii #8

Open condesignpoland opened 9 years ago

condesignpoland commented 9 years ago

Dear Sir, In my backend config file (advanced app) I've set custom session 'session' => [ 'name' => 'BACKENDSESSID', 'cookieParams' => [ 'httpOnly' => true, 'path' => '/', ], ], since then, I cant use KCFinder, because it uses different session.

I've tried to modify core/bootstrap.php in order to pass YII2 session ID, but i can't manage to do that. As far as i know, the problem is that during the lifecycle of Yii Application, vendor files are initiated before Yii. In Yii1 I've used solution mentioned in this article http://www.yiiframework.com/wiki/421/syncing-sessions-between-yii-and-kcfinder/#c10743 but I can't manage to use it in this case.

What is the proper way to handle session between Yii and KCFinder?

fightmyway commented 8 years ago

@condesignpoland do you have solve it ? I am facing the same problem.

condesignpoland commented 8 years ago

Yes, I've solved it. I don't know is this a best solution but it works and makes sense. Check out my attachement. components.zip

Problem was, that during the publishing of assets, CKEditor creates its own session file. I didn't want to modify any of vendor files in order to have ability to update package, so my function is overwriting existing asset session file.

Just check out function "prepareSession()" in CKEditor.php and You should understand how it works. Mby You'll be able to make it even better.

doubleaceru commented 6 years ago

@condesignpoland thank you! I used this, but in my bootstrap.php missed this $search = ['$this->sessionName = "";', '$this->cookieName = "";']; I replaced and used this $search = ["\$this->sessionName = 'BACKENDSESSID';", "\$_COOKIE['BACKENDSESSID'];"]; instead and it work!