Return-Path: <php4beta-return-4555-sascha=schumann.cx@lists.php.net>
Delivered-To: sas@flaubert.foo.bar
Received: (qmail 16766 invoked from network); 17 Sep 1999 06:12:08 -0000
Received: from guerilla.foo.bar (192.168.0.1)
  by flaubert.foo.bar with SMTP; 17 Sep 1999 06:12:08 -0000
Received: (qmail 1922 invoked by uid 1000); 17 Sep 1999 06:15:33 -0000
Delivered-To: sas-sascha@schumann.cx
Received: (qmail 1919 invoked from network); 17 Sep 1999 06:15:33 -0000
Received: from unknown (HELO php.net) (208.247.106.167)
  by hennen32s.iserlohn.netsurf.de with SMTP; 17 Sep 1999 06:15:33 -0000
Received: (qmail 10480 invoked by uid 510); 17 Sep 1999 06:11:04 -0000
Mailing-List: contact php4beta-help@lists.php.net; run by ezmlm
Precedence: bulk
Delivered-To: mailing list php4beta@lists.php.net
Received: (qmail 10473 invoked from network); 17 Sep 1999 06:11:03 -0000
Date: Fri, 17 Sep 1999 08:11:43 +0200
From: Sascha Schumann <sascha@schumann.cx>
To: John Hamlik <johnh@solidtechnology.com>
Cc: "'php4beta@lists.php.net'" <php4beta@lists.php.net>
Message-ID: <19990917081143.A16735@schumann.cx>
References: <5F45F3A100EAD011AA4600A0C9391442335204@voyager.rightline.com> <19990917023755.A9952@schumann.cx>
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary=oyUTqETQ0mS9luUI
X-Mailer: Mutt 0.95.7i
In-Reply-To: <19990917023755.A9952@schumann.cx>
X-Notice: Copyright (c) 1999 Sascha Schumann. All rights reserved.
X-Operating-System: Linux 2.2.13pre6 #4 Sat Sep 11 17:53:09 CEST 1999 alpha
Subject: Re: [PHP4BETA] Session with MySQL

--oyUTqETQ0mS9luUI
Content-Type: text/plain; charset=us-ascii

On Fri, Sep 17, 1999 at 02:37:55AM +0200, Sascha Schumann wrote:
> On Thu, Sep 16, 1999 at 10:51:09AM -0700, John Hamlik wrote:
> > We run php3 on a server cluster and have written our own session object
> > that stores its information in a MySQL database.  I know php4 now
> > includes a session object that is very similiar to the one we have
> > written.  My questions are:
> > 
> > Can the built in session object store its information in a MySQL
> > database?
> 
>     Providing user level functions has to be implemented yet.

    It's implemented now. I've attached a demo which demonstrates
    how this facility can be used.

    Output of script:

    $ ./php save_handler.php
    Content-Type: text/html
    Set-cookie: PHPSESSID=f08b925af0ecb52bdd2de97d95cdbe6b
    
    open (/tmp, PHPSESSID)
    read (f08b925af0ecb52bdd2de97d95cdbe6b)
    write (f08b925af0ecb52bdd2de97d95cdbe6b, foo|i:2;)
    close
    
    You would have to extend the functions to cover MySQL.

-- 

          Regards,

                            Sascha Schumann
                                 Consultant

--oyUTqETQ0mS9luUI
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="save_handler.php"

<?

function open($save_path, $session_name)
{
	echo "open ($save_path, $session_name)\n";

	return true;
}

function close()
{
	echo "close\n";
	return true;
}

function read($key)
{
	echo "read ($key)\n";
	
	return "foo|i:1;";
}

function write($key, $val)
{
	echo "write ($key, $val)\n";
	
	return true;
}

function destroy($key)
{
	return true;
}

function gc($maxlifetime)
{
	return true;
}

session_set_save_handler("open", "close", "read", "write", "destroy", "gc");

session_start();

$foo++;


--oyUTqETQ0mS9luUI
Content-Type: text/plain; charset=us-ascii

-- 
PHP 4 Beta
--oyUTqETQ0mS9luUI--
