CodeIgniter Forums
Sessions - Not Working - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: Sessions - Not Working (/showthread.php?tid=62262)

Pages: 1 2 3


RE: Sessions - Not Working - iD30 - 06-26-2015

(06-26-2015, 04:13 AM)Narf Wrote:
(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.

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.

Well, then there's nothing left but to check your log files, that's what you should've done in the first place.

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.

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.

Firstly, You shouldn't assume anything, you should ask.
Secondly, regardless of me putting up the word "log" or not you STILL shouldn't assumed.
Thirdly, If I felt the log output was relevant to the error or gave any indications of the error (which is doesn't), I would firstly investigate the error and possible solutions myself (making the effort), failing that, I would added the LOG output to my write up to give further help to the people I am asking help from.
Fourth, Just because I am a "first-time poster" shouldn't automatically put me in the category of "not making any effort to help themselves".

I am not or haven't "blamed" you for anything let alone "assuming".


RE: Sessions - Not Working - iD30 - 06-26-2015

(06-26-2015, 05:26 AM)ivantcholakov Wrote: @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.

Thanks for you reply ivantcholakov

The framework download was direct from http://www.codeigniter.com/

Your Low probability - As far as I am aware there isn't any accelerator, but I will double check to make sure - anything is possible.


RE: Sessions - Not Working - Narf - 06-26-2015

(06-26-2015, 05:46 AM)iD30 Wrote: Firstly, You shouldn't assume anything, you should ask.
Secondly, regardless of me putting up the word "log" or not you STILL shouldn't assumed.
Thirdly, If I felt the log output was relevant to the error or gave any indications of the error (which is doesn't), I would firstly investigate the error and possible solutions myself (making the effort), failing that, I would added the LOG output to my write up to give further help to the people I am asking help from.
Fourth, Just because I am a "first-time poster" shouldn't automatically put me in the category of "not making any effort to help themselves".

I am not or haven't "blamed" you for anything let alone "assuming".

So ... you said you felt insulted, in this very post you're telling me 3 times not to assume, yet you're not blaming me for doing that? I find that hard to believe, especially with you being that condescending.

Like it or not, when a first-time poster says "X is not working", having shown no log messages, not even mentioning logs - me and many others will assume that this person has not looked at the log files, because it's the logical thing to do. I was wrong in my assumption and I already admitted that, but don't tell me what to do and what not to do.

Also, a lack of an error message in the logs does not mean they are not relevant to the problem. And in fact, at least one session-related message would appear in the log files if you used $this->load->library('session') like you're supposed to.


RE: Sessions - Not Working - iD30 - 06-26-2015

OK Narf, lets agree to disagree you can keep your assumptions and I will keep my opinions on your approach to my issue.

I came to the forum for help not an argument.

Re: Your Log session-related - Yes it did output this:
Code:
PHP Fatal error:  Call to a member function userdata() on a non-object in /Users/******/Sites/********/application/libraries/Session_management.php on line 169

But I didn't deem this of any use as I know why this error is occurring - due to no Session object being initiated unless put as:
Code:
$this->load->driver('session')

On a more positive note: I seem to of solved the issue by running a complete install of CI 3.0.0 and migrating the files needed across and changing configs where needed, seems as though following the upgrade tutorial didn't work as first expected, possibly due to a copy-paste file that was holding CI 2.0.x code/data, but where I don't know - as previously wrote I removed (deleted) the system file and added the new CI 3.0.0 (after already doing ht e CI 2.0.x - CI 3.0.0 upgrade)

Narf - No hard feelings, thank you for your time and argument, its made my day go faster Wink

ivantcholakov - Thank you for your contribution on this issue too.

I appreciate you taking the time.


RE: Sessions - Not Working - iD30 - 06-26-2015

Actually - after to further testing it hasn't fixed it. :/ Sad


RE: Sessions - Not Working - Narf - 06-26-2015

(06-26-2015, 07:22 AM)iD30 Wrote: OK Narf, lets agree to disagree you can keep your assumptions and I will keep my opinions on your approach to my issue.

I came to the forum for help not an argument.

Agreed.

(06-26-2015, 07:22 AM)iD30 Wrote: Re: Your Log session-related - Yes it did output this:

Code:
PHP Fatal error:  Call to a member function userdata() on a non-object in /Users/******/Sites/********/application/libraries/Session_management.php on line 169

But I didn't deem this of any use as I know why this error is occurring - due to no Session object being initiated unless put as:

Code:
$this->load->driver('session')

Is this from the CodeIgniter logs or somewhere else? I was referring to a line generated by CI_Loader::library() that says if the requested library is loaded or not.


RE: Sessions - Not Working - iD30 - 06-26-2015

I have come across something interesting, I am not sure if it is a bug or the fact it is a now a reserved name, however one of our Controllers is called Session.php, coincidentally & typical this is the main controller for login/out etc.... (session/login).

I renamed the controller and class to Test and then I was able to use the:
Code:
$this->load->library('session')
renamed is back to Session and it bugged out on me.

Can anyone else (@Narf) confirm this to be the same?


RE: Sessions - Not Working - iD30 - 06-26-2015

Narf:  log of all classes being loaded.

Code:
INFO - 2015-06-26 16:40:16 --> Config Class Initialized
INFO - 2015-06-26 16:40:16 --> Hooks Class Initialized
DEBUG - 2015-06-26 16:40:16 --> UTF-8 Support Enabled
INFO - 2015-06-26 16:40:16 --> Utf8 Class Initialized
INFO - 2015-06-26 16:40:16 --> URI Class Initialized
INFO - 2015-06-26 16:40:16 --> Router Class Initialized
INFO - 2015-06-26 16:40:16 --> Output Class Initialized
INFO - 2015-06-26 16:40:16 --> Security Class Initialized
DEBUG - 2015-06-26 16:40:16 --> Global POST, GET and COOKIE data sanitized
INFO - 2015-06-26 16:40:16 --> Input Class Initialized
INFO - 2015-06-26 16:40:16 --> Language Class Initialized
INFO - 2015-06-26 16:40:16 --> Loader Class Initialized
INFO - 2015-06-26 16:40:16 --> Helper loaded: language_helper
INFO - 2015-06-26 16:40:16 --> Helper loaded: url_helper
INFO - 2015-06-26 16:40:16 --> Helper loaded: html_helper
INFO - 2015-06-26 16:40:16 --> Helper loaded: file_helper
INFO - 2015-06-26 16:40:16 --> Controller Class Initialized
INFO - 2015-06-26 16:40:16 --> Helper loaded: form_helper
INFO - 2015-06-26 16:40:16 --> Helper loaded: validation_helper
INFO - 2015-06-26 16:40:16 --> Helper loaded: date_helper
INFO - 2015-06-26 16:40:16 --> Helper loaded: currency_settings_helper
INFO - 2015-06-26 16:40:16 --> Helper loaded: pricing_table_helper
INFO - 2015-06-26 16:40:16 --> Helper loaded: ip_helper
INFO - 2015-06-26 16:40:16 --> Helper loaded: signup_helper
INFO - 2015-06-26 16:40:16 --> Database Driver Class Initialized
INFO - 2015-06-26 16:40:16 --> Form Validation Class Initialized
INFO - 2015-06-26 16:40:16 --> Model Class Initialized
INFO - 2015-06-26 16:40:16 --> Model Class Initialized
INFO - 2015-06-26 16:40:16 --> Model Class Initialized
INFO - 2015-06-26 16:40:16 --> Model Class Initialized
INFO - 2015-06-26 16:40:16 --> Model Class Initialized
INFO - 2015-06-26 16:40:16 --> Session: Class initialized using 'files' driver.
INFO - 2015-06-26 16:40:16 --> Model Class Initialized
INFO - 2015-06-26 16:40:16 --> Language file loaded: language/english/global_lang.php
DEBUG - 2015-06-26 16:40:16 --> Session class already loaded. Second attempt ignored.
DEBUG - 2015-06-26 16:40:16 --> Session_management class already loaded. Second attempt ignored.
DEBUG - 2015-06-26 16:40:16 --> Session class already loaded. Second attempt ignored.
DEBUG - 2015-06-26 16:40:16 --> Config file loaded: /Users/****/Sites/******/application/config/database_tables.php
INFO - 2015-06-26 16:40:16 --> Language file loaded: language/english/activity_log_lang.php
INFO - 2015-06-26 16:40:16 --> Language file loaded: language/english/user_lang.php
DEBUG - 2015-06-26 16:40:16 --> Password_hash class already loaded. Second attempt ignored.
INFO - 2015-06-26 16:40:16 --> Helper loaded: branding_helper
INFO - 2015-06-26 16:40:16 --> Language file loaded: language/english/client_lang.php
INFO - 2015-06-26 16:40:16 --> Model Class Initialized
INFO - 2015-06-26 16:40:16 --> Model Class Initialized
INFO - 2015-06-26 16:40:16 --> Language file loaded: language/english/reseller_lang.php
INFO - 2015-06-26 16:40:16 --> Language file loaded: language/english/credit_lang.php
INFO - 2015-06-26 16:40:16 --> Language file loaded: language/english/dashboard_lang.php
INFO - 2015-06-26 16:40:16 --> Language file loaded: language/english/report_lang.php
INFO - 2015-06-26 16:40:16 --> Model Class Initialized
INFO - 2015-06-26 16:40:16 --> Final output sent to browser
DEBUG - 2015-06-26 16:40:16 --> Total execution time: 0.0623



RE: Sessions - Not Working - Narf - 06-26-2015

(06-26-2015, 09:30 AM)iD30 Wrote: I have come across something interesting, I am not sure if it is a bug or the fact it is a now a reserved name, however one of our Controllers is called Session.php, coincidentally & typical this is the main controller for login/out etc.... (session/login).

I renamed the controller and class to Test and then I was able to use the:

Code:
$this->load->library('session')
renamed is back to Session and it bugged out on me.

Can anyone else (@Narf) confirm this to be the same?

Ah, yes - that's surely the problem. It's not a bug, but also not exactly a reserved name either.

When you call $this->load->library('session'), there are a few checks done before CI knows that you want to actually load the CI_Session class ... class_exists('Session') returns TRUE and it stops there in order to avoid a fatal error.


RE: Sessions - Not Working - iD30 - 06-29-2015

(06-26-2015, 10:55 AM)Narf Wrote:
(06-26-2015, 09:30 AM)iD30 Wrote: I have come across something interesting, I am not sure if it is a bug or the fact it is a now a reserved name, however one of our Controllers is called Session.php, coincidentally & typical this is the main controller for login/out etc.... (session/login).

I renamed the controller and class to Test and then I was able to use the:



Code:
$this->load->library('session')
renamed is back to Session and it bugged out on me.

Can anyone else (@Narf) confirm this to be the same?

Ah, yes - that's surely the problem. It's not a bug, but also not exactly a reserved name either.

When you call $this->load->library('session'), there are a few checks done before CI knows that you want to actually load the CI_Session class ... class_exists('Session') returns TRUE and it stops there in order to avoid a fatal error.

Ahhh @Narf, Yes of course that makes sense.

I have renamed the Session.php Controller/Class to Account.php and this now works great and the Session_Management class loads from the library.

This project uses AJAX calling quite heavily in order to update views etc on the fly, I see that Session Blocking has been implement, so when I user logs in to the system using there user/pass credentials over an AJAX request the session is populated from the Session_Management class (as note previously in this thread) then redirected to the correct page with their privileges, low and be hold the session is now empty and the page is blank.

Is there a safe work around to keep a session active over AJAX or is this something now restricted in CI 3+