Sessions - Not Working |
Hi All
I have recently updated form 2.2.x to 3.0.0 - following the update procedure from codeigniter's website HERE. I have having real issues with the new session library - heres the issue. We have a login section which dependant on the subdomain and user/pass credentials will give you certain privileges from ADMIN / RESELLER / CLIENT / USER In order to determine the correct privileges for the user we have built a customer LIBRARY (location:application/library) which we have called Session_management, this library DOES NOT extend the core SESSION driver/library and never has and has no extension to another class, this library is also auto-loaded, prior to CI 3.0.0 everything was working fine. First this the Session_management does is __construct() Code: $this->CI =& get_instance(); Prior to CI 3.0.0 I has no issues in using the Code: $this->CI->load->library('session') Code: $this->CI->load->diver('session'); When a user submits their user/pass credentials a CONTROLLER session/signin is requested which runs firstly form validation, providing everything is successfully, the Session_management login method is called. Code: $success = $this->session_management->login($this->input->post('email'), $this->input->post('password')); In the LOGIN method in the Session_management class a bunch of sessions are set using $this->session->set_userdata() Code: $this->session->set_userdata('user_id', 0); However when I var_dump() the session for all its session data it has NOTHING and I can't why this is, no session data is there except my protected fields form the config, which I have double checked and triple checked and are working fine, my sess_save_path is storing the session files correctly, and the rest of the sess configs are also correct. Code: $config['sess_driver'] = 'files'; This is a development website on my local OS X iMac, as I say prior to CI 3.0.0 everything was working fine. Any help or information or anything that could possible put me in the right direction would be appreciated. Michael
You are wrong about loading the session as a driver.
Just like before, it must be loaded as a library: PHP Code: $this->load->library('session'); The tricky part is configuring the session settings. I didn't get it working with $config['sess_driver'] = 'files'; Therefore, I switched to $config['sess_driver'] = 'database'; and I added a ci_sessions table to my database. No problems with sessions since then. (06-25-2015, 10:34 AM)Wouter60 Wrote: You are wrong about loading the session as a driver. Just to add to this message re: database sessions. Database sessions were my first option, a have revamp the database columns and indexes to suit CI 3.0.0 as the documentation mentions and session were and are storing when I change my config to use the database, however reading the performance differences between Files against Database under high load, File sessions will out perform database session and since the website / platform I am creating will be under high load, database sessions aren't the way forward. (06-25-2015, 10:34 AM)Wouter60 Wrote: You are wrong about loading the session as a driver. Thanks for your reply Wouter60, however, in my problem I said I "HAVE" to load it as a driver, I don't have a choice, I also asked if someone could explain why I have that would be great. I have read the documentation and have seen how to initialise the session library - http://www.codeigniter.com/userguide3/li...-a-session If I do attempt to load it as a library Code: $this->load->library('session') This is what I get Code: A PHP Error was encountered For your ref: line 38 is: Code: $this->session = $this->CI->session; This is after trying to load the session library Code: $this->CI->load->library('session'); Any further help would be appreciated
I assume you've copy-pasted the new CI files over the old ones instead of deleting the old system/ directory and putting the new one in its place ... If that's the case - delete system/libraries/Session.php.
(06-26-2015, 02:59 AM)Narf Wrote: I assume you've copy-pasted the new CI files over the old ones instead of deleting the old system/ directory and putting the new one in its place ... If that's the case - delete system/libraries/Session.php. Thanks for your reply Narf, I really thought you were on to something then. I have just checked my system dir for the redundant/stray Session.php but it wasn't there, to double make sure I have just removed the old System dir and added the new CI 3.0.0 System dir in its place. Any further help would be appreciated. (06-26-2015, 03:04 AM)iD30 Wrote:(06-26-2015, 02:59 AM)Narf Wrote: I assume you've copy-pasted the new CI files over the old ones instead of deleting the old system/ directory and putting the new one in its place ... If that's the case - delete system/libraries/Session.php. Well, then there's nothing left but to check your log files, that's what you should've done in the first place. (06-26-2015, 03:22 AM)Narf Wrote:(06-26-2015, 03:04 AM)iD30 Wrote:(06-26-2015, 02:59 AM)Narf Wrote: I assume you've copy-pasted the new CI files over the old ones instead of deleting the old system/ directory and putting the new one in its place ... If that's the case - delete system/libraries/Session.php. Without trying to sound disrespectful to you Narf, but I find your remark rather insulting "check your log files, that's what you should've done in the first place". Do you honestly think I would of wasted my time, Codeigniter's forum members time with a write up of my issue and gone through the whole process to NOT have checked my log files. Every project I am working on, I run tail -f on my log files to give me live log updates. Thanks for your time and "advice" Narf. (06-26-2015, 03:33 AM)iD30 Wrote:(06-26-2015, 03:22 AM)Narf Wrote:(06-26-2015, 03:04 AM)iD30 Wrote:(06-26-2015, 02:59 AM)Narf Wrote: I assume you've copy-pasted the new CI files over the old ones instead of deleting the old system/ directory and putting the new one in its place ... If that's the case - delete system/libraries/Session.php. So I was wrong in assuming that you didn't check your log files. Yet none of your posts mention the word "log" or include any log output ... Yes, I honestly did think that you didn't check your log files. Few people do, you're a first-time poster, and a LOT of people come here asking for help without making any effort to help themselves. Don't blame me for assuming that you haven't checked everything.
@iD30
If $this->CI->load->diver('session'); is still mysteriously needed, there are two more probable causes I can guess: - Maybe the source you are using for upgrading is an old development snapshot CI 3.0-dev, not the final 3.0.0 release. For being sure, in your server check with echo CI_VERSION; what actually is returned. - (Low probability) Presence of code execution accelerator like apc or another one, then it should be reset. |
Welcome Guest, Not a member yet? Register Sign In |