Re: CGI::Session with MySQL Driver



Fabian Pilkowski a écrit :
Subject: CGI::Session with MySQL Driver

* Alexandre Jaquet schrieb:


Does anyone 've a sample test script I can use.

I've search the web but didn't find something relevant.


Take the one I recently fixed for you in your last thread (look at
<news:3fvvicF9s5ovU1@xxxxxxxxxxxxxx> if you don't remember) as basis.
Change the call of CGI::Session's constructor from

    my $session = new CGI::Session( "driver:File", undef,
                                    {Directory => 'C:/sessions'} );

to

my $dbh = DBI->connect( ... ) # create databasehandle
my $session = new CGI::Session( "driver:MySQL", undef,
{ Handle => $dbh} );
Pay attention to the second parameter which should be remain as it
already is in the various situations. Then read the docs to learn how
creating the necessary table in your MySQL database, at


    http://search.cpan.org/~sherzodr/CGI-Session-3.95/Session/MySQL.pm

That's all. If you have a specific problem, try to check the docs first
-- perhaps there is already mentioned a solution.

regards,
fabian

I've read this doc, but it's doesn't seem to have example with new defined field


I want to store user_name in session table

$dbh is previously initialized

$CGI::Session::MySQL::TABLE_NAME = 'session';
my $SESSION = new CGI::Session("driver:MySQL",$query, $dbh);	
$SESSION->store($dbh,$id,'',"user_name	=> $username");

error message :

Can't connect to data source , no database driver specified and DBI_DSN env var not set at C:/indigoperl/perl/site/lib/CGI/Session/MySQL.pm line

Can't get DBI::db=HASH(0x1f21af0)->{Handle}: unrecognised attribute at C:/indigoperl/perl/site/lib/CGI/Session/MySQL.pm line 131
.