• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random occurance of session-error

#1
[eluser]heavenquake[/eluser]
Hello. First and foremost: I'm inexperienced on these forums, but I've tried my best to search before posting. I didn't find anything of relevance, but please bear with me if there was something I overlooked Smile

The bug, at least that's what I think it is, seems to be in the Session-library of CI.

On random occurances, about 20-30% of my pageloads, but sometimes multiple loads in a row, I get the following two messages.

The first is a Codeigniter-style exception:
Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined property: Master::$db

Filename: libraries/Session.php

Line Number: 746

While the second is a standard PHP fatal error:
Code:
Fatal error: Call to a member function where() on a non-object in /home/heavenquake/documents/programming/webpages/HqCMS/system/libraries/Session.php on line 746

I am running this on localhost, and my environment is as follows:
Code:
Debian GNU/Linux
Apache2
PHP5
CodeIgniter 1.7.0 w. Modular Extensions(although I highly doubt this library to be the cause, as it doesn't fiddle with the Session library at all)

My browser is Iceweasel(Firefox), if that has anything to say.

It happens on any controller and any view - both those that utilize sessions and those that doesn't (however, I have the session library autoloaded).

EDIT: Perhaps I should add that I'm not yet doing any database-work, and that I'm thus not trying to store sessiondata in a database. I don't even load the database library.

#2
[eluser]Pascal Kriete[/eluser]
I assume Master is your controller name?

Go into application/config/config.php and make sure that $config['sess_use_database'] is set to false. It should never get to line 746 if you're not using a database.

#3
[eluser]heavenquake[/eluser]
[quote author="Pascal Kriete" date="1227817560"]I assume Master is your controller name?

Go into application/config/config.php and make sure that $config['sess_use_database'] is set to false. It should never get to line 746 if you're not using a database.[/quote]
Master was the controller name in that given case, yes, but like I said it's not controller-specific, as it happens on any controller.

and yes, it's set to false in the config.

BTW I've not experienced any problems of the sort today, and the only alteration I've done today from yesterdays code, was add a few custom (array related)helpers. It seems really random..

#4
[eluser]heavenquake[/eluser]
More strangeness.

I've now started using the database (for user controls only, not session storage), and the former error is gone for good.

However, I get the following error at random, also around 20% of my pageloads.

Code:
An Error Was Encountered

Unable to load the requested language file: language/db_lang.php
I'm *not* using any language file called db_lang anywhere, and I have no idea why it sometimes tries to load it, but not other times. What's going on?

EDIT: Alright, it looks like it's trying to save my sessiondata in the database, even though it's set not to.

I created an empty db_lang.php file in my language directory, and now the occuring error is
Code:
Error Number: 1146

Table 'HqCMS.N' doesn't exist

DELETE FROM `N` WHERE `last_activity` < 1164918720

#5
[eluser]heavenquake[/eluser]
UPDATE:
I seem to have caught the bug.

In system/libraries/Session.php, on line 280 is this:
Code:
// Run the update query

$this->CI->db->where('session_id', $this->userdata['session_id']);

$this->CI->db->update($this->sess_table_name, array('last_activity' => $this->userdata['last_activity'], 'user_data' => $custom_userdata));
when I replaced that with
Code:
if($this->sess_use_database === TRUE)
{

    // Run the update query

    $this->CI->db->where('session_id', $this->userdata['session_id']);

    $this->CI->db->update($this->sess_table_name, array('last_activity' => $this->userdata['last_activity'], 'user_data' => $custom_userdata));
}
Everything worked out as if it never happened.

#6
[eluser]heavenquake[/eluser]
This is extremely odd.

For some reason, the sessions get destroyed when I load any other page - or even loads the same page again(that is, not refreshing it, but typing in the URL again).

the session library is in my autoload array.

These strange errors are beginning to get on my nerves.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.