[Workaround found] CodeIgniter 3.0 cannot access native $_SESSION |
I have observe the file.
It contains something like this: __ci_last_regenerate|i:1429289613;created_db| How could I decode them into associative array?
Did you found a solution for this, becouse i have almost same issue.
Trying to access $_SESSION from a config.php for Ckfinder installation. But wifth the new CI3 im not able to do this anymore. The reson i will do this is to have dynamic upload path depending on user id that is logged in to my system.
I solved using a snippet, it works for me when combine kcfinder!!!
EXAMPLE In my View (using a JQuery Function): PHP Code: $.ajax({ In my Snippet: PHP Code: <? I apologize for my limited and ugly English (04-17-2015, 10:05 AM)gofrendi Wrote: I have observe the file. http://php.net/manual/en/session.configu...ze-handler In most cases, the data is just serialized, but the method used to do so depends on your server's configuration. While you could just attempt to use unserialize() to retrieve the data, it would really work better if you just used a session handler, as CI3 does, since PHP handles the serialization for you. The KCFinder website includes some information on how to configure a session handler for it, too. (04-16-2015, 11:01 PM)gofrendi Wrote:(04-16-2015, 05:35 AM)gadelat Wrote: You don't necessarily need the same handler, just simply emulate the behaviour a bit. It's quite simple: get value of cookie (by default ci_session) and load the content of the session file containing this name (if you use files driver) from directory specified in $config['sess_save_path'] That was great idea. I found that the content of CI session file and native PHP session file has same format and not encrypted. CodeIgniter write the file itself and put the file in the folder path we set in $config['sess_save_path']. But CodeIgniter create the file with name format [session_name].[session_id]. So if default session name is 'PHPSESSID' and the session id is '4513d5e583058952c20c0e38de33a39deaa17ed2', the file will be named 'PHPSESSID4513d5e583058952c20c0e38de33a39deaa17ed2'. It is different with native PHP filenaming, which is using string 'sess_' and session id by hard-coded. The simplest way I can do is by modifying libraries/Session/drivers/Session_files_driver.php file so it use 'sess_' prefix instead of session_name, like this in line 128-131 (I use CodeIgniter 3.0.2): Code: $this->_file_path = $this->_config['save_path'].DIRECTORY_SEPARATOR And in external php file, I add session_save_path() before session_start() to change the session save path, so the native PHP session read and write to the same session file. Code: <?php Maybe the last thing is to find the way to extend the Session_files_driver.php if possible (I didn't try it) or create our own session files driver. Quote:Quote:UPDATE: |
Welcome Guest, Not a member yet? Register Sign In |