Re: Apache::Session::MySQL question regarding lenght of _session_id

2000-12-19 Thread Jeffrey W. Baker

On Mon, 18 Dec 2000, Andreas Marienborg wrote:

 I just can't seem to find any info on how to specify that Apache::Session
 should create session_id's that are shorter than 32 hex chars? could
 someone point me in the right direction??

You can use the argument 'IDLength' when using
Apache::Session::Generate::MD5 (the default), or you can replace that
class with your own class to generate the IDs you desire.

See the obscure Apache::Session::Generate::MD5 perldoc.

-jwb




Apache::Session::MySQL question regarding lenght of _session_id

2000-12-18 Thread Andreas Marienborg

I just can't seem to find any info on how to specify that Apache::Session
should create session_id's that are shorter than 32 hex chars? could
someone point me in the right direction??

thanks in advance

Andreas


-- 
Andreas Marienborg  +47 92 28 63 82
[EMAIL PROTECTED]   www.palle.net




Re: Apache::Session::MySQL question regarding lenght of _session_id

2000-12-18 Thread Aaron E. Ross

at a time earlier than now, Andreas Marienborg wrote:
 I just can't seem to find any info on how to specify that Apache::Session
 should create session_id's that are shorter than 32 hex chars? could
 someone point me in the right direction??

 Just write a module to sub class Apache::Session. Apache::Session::MySQL is 
 remarkably simple.  Here it is:

package Apache::Session::MySQL;
 
use strict;
use vars qw(@ISA $VERSION);
 
$VERSION = '1.01';
@ISA = qw(Apache::Session);
 
use Apache::Session;
use Apache::Session::Lock::MySQL;
use Apache::Session::Store::MySQL;
use Apache::Session::Generate::MD5;
use Apache::Session::Serialize::Storable;
 
sub populate {
my $self = shift;
 
$self-{object_store} = new Apache::Session::Store::MySQL $self;
$self-{lock_manager} = new Apache::Session::Lock::MySQL $self;
$self-{generate} = \Apache::Session::Generate::MD5::generate;
$self-{validate} = \Apache::Session::Generate::MD5::validate;
$self-{serialize}= \Apache::Session::Serialize::Storable::serialize;
$self-{unserialize}  = \Apache::Session::Serialize::Storable::unserialize;
 
return $self;
}
 
1;

You can have any subroutine you want generate id's. Just change the two lines
where generate is set to Apache::Session::Generate::MD5::generate and validate
to Apache::Session::Generate::MD5::validate. For example:

package Apache::Session::MyOwnPackage;
 
use strict;
use vars qw(@ISA $VERSION);
 
$VERSION = '1.01';
@ISA = qw(Apache::Session);
 
use Apache::Session;
use Apache::Session::Lock::MySQL;
use Apache::Session::Store::MySQL;
use Apache::Session::Serialize::Storable;
 
sub populate {
my $self = shift;
 
$self-{object_store} = new Apache::Session::Store::MySQL $self;
$self-{lock_manager} = new Apache::Session::Lock::MySQL $self;
$self-{generate} = \generate;
$self-{validate} = \validate;
$self-{serialize}= \Apache::Session::Serialize::Storable::serialize;
$self-{unserialize}  = \Apache::Session::Serialize::Storable::unserialize;
 
return $self;
}

sub generate
{
# some code to generate ids
}

sub validate
{
# some code to validate ids
}
 
1;

Of course, you'll actually need to write some code to generate and validate
ids. :)

HTH, 
 Aaron
 
 
 thanks in advance
 
 Andreas
 
 
 -- 
 Andreas Marienborg+47 92 28 63 82
 [EMAIL PROTECTED] www.palle.net

-- 

---
 Caution! The beverage you are about to enjoy may be hot.




Re: Apache::Session::MySQL question regarding lenght of _session_id

2000-12-18 Thread Andreas Marienborg

On Mon, 18 Dec 2000, Aaron E. Ross wrote:

 at a time earlier than now, Andreas Marienborg wrote:
  I just can't seem to find any info on how to specify that Apache::Session
  should create session_id's that are shorter than 32 hex chars? could
  someone point me in the right direction??

  Just write a module to sub class Apache::Session. Apache::Session::MySQL is
  remarkably simple.  Here it is:


Thanks for pointing this out..however, I found a better way I thought I'd
share with the list:

The Apache::Session::Generate::MD5 module actually checks if there is an
arg called 'IDLength' when it generates the ID...so I just had to add an
IDLength = 8 to my initial Session tie, and everything worked nicely from
there on :)

Thanks for pointing me in the right direction!


-- 
Andreas Marienborg  +47 92 28 63 82
[EMAIL PROTECTED]   www.palle.net