Session Tables and error 1114

Discussion of general topics related to the new version and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Forum rules
Discussion of general topics related to the new release and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Post Reply
Michaelo
Registered User
Posts: 106
Joined: Thu Apr 01, 2004 7:56 am
Location: Dublin

Session Tables and error 1114

Post by Michaelo »

The following offered for discussion only...

Should it not be possible to use the following code to fix some session problems associated with ANONYMOUS users.
Error 1114 (sessions table full) is common on many sites and several fixes have been posted but after examining several sites I tend to believe most problems stem from normal browsing by anonymous users. If the max session is 500 then when 500 people visit your site all your sessions are eaten up and you get the 1114 error...

This simple bit of code (a combination of code from phpBB3 and an official recommenced fix for phpBB2.1.x) could solve some problems...

Code: Select all

$error = TRUE;
if (SQL_LAYER == "mysql" || SQL_LAYER == "mysql4")
{
    $sql_error = $db->sql_error($result);
    if ($sql_error["code"] == 1114)
    {

      // delete old guest sessions
      $sql = 'DELETE FROM ' . SESSIONS_TABLE . '
         WHERE session_user_id = ' . ANONYMOUS . '
            AND session_time < ' . (int) ($this->time_now - $config['session_length']);
      $db->sql_query($sql);

    }
    if ($db->sql_query($sql))
    {
        $error = FALSE;
    }
}
if ($error)
{
    message_die(CRITICAL_ERROR, "Error creating new session", "", __LINE__, __FILE__, $sql);
}
Simply replace the current ERROR REPORT CODE with the above code...

Mike
Mods: Forum Icons Enhancement, Kiss Portal Engine
Links:
Kiss Portal Engine (dev site) Stargate Portal (archive site) ...
Styles: Technika

Post Reply