in reply to CGI::Session::MySQL

Here is how I do it, also based on the cookbook.
#!/usr/bin/perl -W # # use CGI::Session; use CGI::Session::MySQL; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); use DBI; use strict; my $config = { DSN => 'DBI:mysql:dc151fc_session', MySQLunm => 'xxxx', MySQLpwd => 'xxxx', cartURL => 'http://xxxx.com/cgi-bin/cart.pl?cmd +='}; my $DEBUG = 1; my $cgi; my $session; my $cart; $cgi = new CGI; my $dbh = &createDBconnection( $config->{DSN}, $config->{MySQLunm}, $c +onfig->{MySQLpwd} ); $session = new CGI::Session("driver:MySQL", $cgi, {Handle=>$dbh}); my $cookie = $cgi->cookie(-name=>'CGISESSID', -value=>$session->id, -e +xpires=>'+1d'); print $cgi->header(-cookie=>$cookie);
That code is working in may application.

....john

Replies are listed 'Best First'.
Re: Re: CGI::Session::MySQL
by Cody Pendant (Prior) on Aug 07, 2003 at 03:35 UTC
    Thank you, that looks exactly what I need.

    What's that "dc151fc_session" all about, if you don't mind my asking -- that's your table name in the db, or the db name?



    ($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss') =~y~b-v~a-z~s; print
      Hi!

      the dc151fc_session is the database name. All my db names are prevfixed with the first seven characters of the domain name they are used by. The table name, as I recall is 'sessions' - the default expected by CGI::Session::MySQL.

      I'm glad it helped, I only got it working for the first time yesterday!

      ....john

        Just a note to say it's working just fine now, thanks again.

        I haven't got anything especially useful in the sessions table, just an id which is the session id and a hash with various bits of data in the session details.

        Is there a way to get useful things into useful fields in the table so that I can sort by them or search by them? Usernames, expiries, that kind of thing?



        ($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss') =~y~b-v~a-z~s; print