Re: Storing session data with ADOdb and MySQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 18, 2008 at 7:38 AM, Simpson, John R
<john_simpson@xxxxxxxxxx> wrote:
> I want to store our session data in a database so that we can support multiple SquirrelMail servers, and I've been using the instructions here: http://squirrelmail.org/wiki/SessionsInDatabase to set up ADOdb.
>
> I think I'm missing something, possibly having to do with custom session handlers.  I've found a lot of references to session handling bugs in php4 (we're using php 5.1.6), and a great discussion that seems closely related to my problem here: http://thread.gmane.org/gmane.mail.squirrelmail.devel/8949/focus=8962
>
> We're running SquirrelMail 1.4.15 on CentOS 5.2 and I've installed ADOdb 4.81 using the RPM php-adodb-4.81-1.el5.rf.noarch.rpm.
>
> Login.php is failing with the following error:
>
> PHP Fatal error:  session_start() [<a href='function.session-start'>function.session-start</a>]: Failed to initialize storage module: user (path: /var/lib/php/session) in /usr/share/squirrelmail/functions/global.php on line 369.
>
> session_start() was called from login.php, sqsession_is_active(), line 108, which is actually the second time sqsession_is_active gets called.  When this happens I'm left with a blank page that has an empty BODY.
>
> I have a test script in the squirrelmail/src directory so it's subject to the same php_value auto_prepend_file of sessiondb.php as SquirrelMail and it is working fine -- logging into the database and happily storing session data.
>
> I've searched through the SquirrelMail, PHP, and ADOdb documentation, mailing list archives, forums and everything that google can come up with and haven't found anything that solves the problem.  There are hints that session_destroy() is wiping out more than it should when it is called prior to the session_start() call that fails, but I haven't found a reference to setting up custom_session_handlers for ADOdb.
>
> Can anyone point me in the right direction, or is there another preferred way of storing session data in a database?

Forgive me for not having the time to really sit down with the details
of your issue, but it looks to me like you are probably hitting the
PHP issues discussed in the thread you found on our developers' list.
The result of that conversation was code inserted into login.php with
the following comments that might explain why your attempts are
failing.  If this works for you, that wiki page should be updated.

/**
 * Allow administrators to define custom session handlers
 * for SquirrelMail without needing to change anything in
 * php.ini (application-level).
 *
 * In config_local.php, admin needs to put:
 *
 *     $custom_session_handlers = array(
 *         'my_open_handler',
 *         'my_close_handler',
 *         'my_read_handler',
 *         'my_write_handler',
 *         'my_destroy_handler',
 *         'my_gc_handler',
 *     );
 *     session_module_name('user');
 *     session_set_save_handler(
 *         $custom_session_handlers[0],
 *         $custom_session_handlers[1],
 *         $custom_session_handlers[2],
 *         $custom_session_handlers[3],
 *         $custom_session_handlers[4],
 *         $custom_session_handlers[5]
 *     );
 *
 * We need to replicate that code once here because PHP has
 * long had a bug that resets the session handler mechanism
 * when the session data is also destroyed.  Because of this
 * bug, even administrators who define custom session handlers
 * via a PHP pre-load defined in php.ini (auto_prepend_file)
 * will still need to define the $custom_session_handlers array
 * in config_local.php.
 */



> sessiondb.php:
> <?php
>    include_once ('/var/www/adodb/adodb.inc.php');
>    $ADODB_SESSION_DRIVER = 'mysql';
>    $ADODB_SESSION_CONNECT = 'localhost';
>    $ADODB_SESSION_USER = 'root';
>    $ADODB_SESSION_PWD = '********';
>    $ADODB_SESSION_DB = 'webmail';
>    include_once (ADODB_DIR . '/session/adodb-session.php');
> ?>
>
> adotest.php
> <?php
>    session_start();
>
>    #
>    # Test session vars, the following should increment on refresh
>    #
>    $_SESSION['AVAR'] += 1;
>    print "<p>\$_SESSION['AVAR']={$_SESSION['AVAR']}</p>";
> ?>
>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
-----
squirrelmail-users mailing list
Posting guidelines: http://squirrelmail.org/postingguidelines
List address: squirrelmail-users@xxxxxxxxxxxxxxxxxxxxx
List archives: http://news.gmane.org/gmane.mail.squirrelmail.user
List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-users

[Index of Archives]     [Video For Linux]     [Yosemite News]     [Yosemite Photos]     [gtk]     [KDE]     [Cyrus SASL]     [Gimp on Windows]     [Steve's Art]     [Webcams]

  Powered by Linux