perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Vanasco <...@2xlp.com>
Subject Re: apache::session not writing to db
Date Mon, 19 Dec 2005 15:41:07 GMT
first-

	add a timestamp column to your db store.  you're going to need to  
clean out old sessions somehow.

mysql> describe sessions;
+-----------+-------------+------+-----+-------------------+-------+
| Field     | Type        | Null | Key | Default           | Extra |
+-----------+-------------+------+-----+-------------------+-------+
| id        | varchar(32) |      | PRI |                   |       |
| time      | timestamp   | YES  |     | CURRENT_TIMESTAMP |       |
| a_session | text        | YES  |     | NULL              |       |
+-----------+-------------+------+-----+-------------------+-------+

second -

this is off of my code.  maybe this will help.

SiteUserClass:

	my $ApacheSessionOptions = 	
	   {
	      'MySQL' =>
	      {
			DataSource => 'dbi:mysql:rs_session',
			UserName   => 'rs_session_user',
			Password   => 'rs_session_pass',
			LockDataSource => 'dbi:mysql:rs_session',
			LockUserName   => 'rs_session_user',
			LockPassword   => 'rs_session_pass',
	      }
	   };

	constructor:
		$this->{'ApacheSessionOptions'}		= $ApacheSessionOptions-> 
{$ApacheSessionStore};

MyFramework Site User Base Class

	if 	( ${$this->{'ApacheSessionStore'}} eq 'MySQL' )
	{
		DEBUG >0 && print STDERR "\nTying? Apache::Session::MySQL -  
$sessionID\n";
		eval{ tie %{$this->{'__SESSION'}} , 'Apache::Session::MySQL',  
$sessionID, $this->{'ApacheSessionOptions'} } ;
		if ($@)
		{
			$error = 1;
			$sessionID = undef;
		}
	}


Thirdly-

you can either turn debugging on with the DBI.  set tracelevel to 1  
or 2.  i don't know how to do that through apache::sesssion, you  
might be able to subclass the connect string.  or set a general  
default for the DBI.  i've just done it per handle on instantiation  
before.  if you can do that, it helps a ton.

another option is to restart mysql and have it log all queries, then  
tail that log in a terminal window.  i often do that on my dev box,  
and just run a cronjob to truncate the file every night.  also helps  
a ton.

	


Mime
View raw message