[25902] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 8130 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 30 09:10:17 2005

Date: Mon, 30 May 2005 06:10:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 30 May 2005     Volume: 10 Number: 8130

Today's topics:
        CGI::Session with MySQL Driver <alexj@freesurf.ch>
    Re: CGI::Session with MySQL Driver <mark.clementsREMOVETHIS@wanadoo.fr>
    Re: CGI::Session with MySQL Driver <pilkowsk@informatik.uni-marburg.de>
    Re: CGI::Session with MySQL Driver <alexj@freesurf.ch>
    Re: CGI::Session with MySQL Driver <mark.clementsREMOVETHIS@wanadoo.fr>
    Re: CGI::Session with MySQL Driver <1usa@llenroc.ude.invalid>
    Re: CGI::Session with MySQL Driver <alexj@freesurf.ch>
    Re: CGI::Session with MySQL Driver <mark.clementsREMOVETHIS@wanadoo.fr>
    Re: CGI::Session with MySQL Driver <alexj@freesurf.ch>
    Re: CGI::Session with MySQL Driver <mark.clementsREMOVETHIS@wanadoo.fr>
    Re: CGI::Session with MySQL Driver <alexj@freesurf.ch>
    Re: CGI::Session with MySQL Driver <alexj@freesurf.ch>
    Re: CGI::Session with MySQL Driver <1usa@llenroc.ude.invalid>
    Re: CGI::Session with MySQL Driver <mark.clementsREMOVETHIS@wanadoo.fr>
    Re: CGI::Session with MySQL Driver <alexj@freesurf.ch>
    Re: CGI::Session with MySQL Driver <pilkowsk@informatik.uni-marburg.de>
    Re: CGI::Session with MySQL Driver <alexj@freesurf.ch>
    Re: CGI::Session with MySQL Driver <mark.clementsREMOVETHIS@wanadoo.fr>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 30 May 2005 12:44:04 +0200
From: Alexandre Jaquet <alexj@freesurf.ch>
Subject: CGI::Session with MySQL Driver
Message-Id: <429aee76$0$1146$5402220f@news.sunrise.ch>

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

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

cheers :)


------------------------------

Date: 30 May 2005 10:58:38 GMT
From: "Mark Clements" <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: CGI::Session with MySQL Driver
Message-Id: <429af1de$0$3126$8fcfb975@news.wanadoo.fr>

Alexandre Jaquet wrote:

> Does anyone 've a sample test script I can use.
> 
> I've search the web but didn't find something relevant.
> 
> cheers :)

er - how about

t/mysql.t

from the CGI::Session distribution itself.

Mark


------------------------------

Date: Mon, 30 May 2005 13:03:07 +0200
From: Fabian Pilkowski <pilkowsk@informatik.uni-marburg.de>
Subject: Re: CGI::Session with MySQL Driver
Message-Id: <3g0a6eF9utkrU1@individual.net>

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@individual.net> 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


------------------------------

Date: Mon, 30 May 2005 13:15:52 +0200
From: Alexandre Jaquet <alexj@freesurf.ch>
Subject: Re: CGI::Session with MySQL Driver
Message-Id: <429af5eb$0$1145$5402220f@news.sunrise.ch>

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@individual.net> 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


------------------------------

Date: 30 May 2005 11:36:54 GMT
From: "Mark Clements" <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: CGI::Session with MySQL Driver
Message-Id: <429afad5$0$3104$8fcfb975@news.wanadoo.fr>

Alexandre Jaquet wrote:

> Fabian Pilkowski a écrit :
> > Subject: CGI::Session with MySQL Driver
> > 
<snip>
> > 
> > http://search.cpan.org/~sherzodr/CGI-Session-3.95/Session/MySQL.pm
> > 

> 
> 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

Why are you calling store? This is not mentioned in the documentation
and should be considered an internal method, ie don't call it yourself.

What does

$dbh->ping()

return?

Is your script failing at new or at store?

Until you learn to ask yourself this sort of question you aren't going
to make much progress.

Mark


------------------------------

Date: Mon, 30 May 2005 11:45:49 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: CGI::Session with MySQL Driver
Message-Id: <Xns96664EC4CB68asu1cornelledu@127.0.0.1>

Alexandre Jaquet <alexj@freesurf.ch> wrote in news:429af5eb$0$1145$5402220f@news.sunrise.ch:

> 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

<URL: http://search.cpan.org/~sherzodr/CGI-Session-3.95/Session/Tutorial.pm#CREATING_NEW_SESSION>


-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


------------------------------

Date: Mon, 30 May 2005 14:02:59 +0200
From: Alexandre Jaquet <alexj@freesurf.ch>
Subject: Re: CGI::Session with MySQL Driver
Message-Id: <429b00f5$0$1156$5402220f@news.sunrise.ch>

A. Sinan Unur a écrit :
> Alexandre Jaquet <alexj@freesurf.ch> wrote in news:429af5eb$0$1145$5402220f@news.sunrise.ch:
> 
> 
>>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
> 
> 
> <URL: http://search.cpan.org/~sherzodr/CGI-Session-3.95/Session/Tutorial.pm#CREATING_NEW_SESSION>
> 
> 

nothing about storing data in database ...

$SESSION = new CGI::Session( "driver:MySQL", undef,  { Handle =>$dbh} );	
$SESSION->store($dbh,$SESSION->id,'',"user_name	=> $username");

store now return : Can't use string ("b7f26a2095fb2ff4e11e8ae1295d767e") 
as an ARRAY ref while "strict refs" in use at ...

the string b7f26a2095fb2ff4e11e8ae1295d767e represent the sessionid 
what's wrong ?



------------------------------

Date: 30 May 2005 12:07:05 GMT
From: "Mark Clements" <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: CGI::Session with MySQL Driver
Message-Id: <429b01e9$0$11700$8fcfb975@news.wanadoo.fr>

Alexandre Jaquet wrote:

> A. Sinan Unur a écrit :
> > Alexandre Jaquet <alexj@freesurf.ch> wrote in
> > news:429af5eb$0$1145$5402220f@news.sunrise.ch:
> > 
> > 
> > > 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
> > 
> > 
> > <url:
> > http://search.cpan.org/~sherzodr/CGI-Session-3.95/Session/Tutorial.p
> > m#CREATING_NEW_SESSION>
> > 
> > 
> 
> nothing about storing data in database ...
> 
> $SESSION = new CGI::Session( "driver:MySQL", undef,  { Handle =>$dbh}
> ); $SESSION->store($dbh,$SESSION->id,'',"user_name	=> $username");
> 
> store now return : Can't use string
> ("b7f26a2095fb2ff4e11e8ae1295d767e") as an ARRAY ref while "strict
> refs" in use at ...
> 
> the string b7f26a2095fb2ff4e11e8ae1295d767e represent the sessionid
> what's wrong ?

You really don't read the documentation do you?

From the tutorial that Sinan pointed you at:

         @my_array = ("apple", "grapes", "melon", "casaba");
         $session->param("fruits", \@my_array);

Don't use store, use param.

Don't make us read the docs for you.

Mark


------------------------------

Date: Mon, 30 May 2005 14:11:47 +0200
From: Alexandre Jaquet <alexj@freesurf.ch>
Subject: Re: CGI::Session with MySQL Driver
Message-Id: <429b0305$0$1156$5402220f@news.sunrise.ch>

Mark Clements a écrit :
> Alexandre Jaquet wrote:
> 
> 
>>A. Sinan Unur a écrit :
>>
>>>Alexandre Jaquet <alexj@freesurf.ch> wrote in
>>>news:429af5eb$0$1145$5402220f@news.sunrise.ch:
>>>
>>>
>>>
>>>>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
>>>
>>>
>>><url:
>>>http://search.cpan.org/~sherzodr/CGI-Session-3.95/Session/Tutorial.p
>>>m#CREATING_NEW_SESSION>
>>>
>>>
>>nothing about storing data in database ...
>>
>>$SESSION = new CGI::Session( "driver:MySQL", undef,  { Handle =>$dbh}
>>); $SESSION->store($dbh,$SESSION->id,'',"user_name	=> $username");
>>
>>store now return : Can't use string
>>("b7f26a2095fb2ff4e11e8ae1295d767e") as an ARRAY ref while "strict
>>refs" in use at ...
>>
>>the string b7f26a2095fb2ff4e11e8ae1295d767e represent the sessionid
>>what's wrong ?
> 
> 
> You really don't read the documentation do you?
> 
> From the tutorial that Sinan pointed you at:
> 
>          @my_array = ("apple", "grapes", "melon", "casaba");
>          $session->param("fruits", \@my_array);
> 
> Don't use store, use param.
> 
> Don't make us read the docs for you.
> 
> Mark

That's what I've try first it's doesn't store value key pair user_name 
$username ...


------------------------------

Date: 30 May 2005 12:13:26 GMT
From: "Mark Clements" <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: CGI::Session with MySQL Driver
Message-Id: <429b0365$0$11682$8fcfb975@news.wanadoo.fr>

Alexandre Jaquet wrote:

> Mark Clements a écrit :
> > Alexandre Jaquet wrote:
> > 
> > 
> > > A. Sinan Unur a écrit :
> > > 
> >>>Alexandre Jaquet <alexj@freesurf.ch> wrote in
> > > > news:429af5eb$0$1145$5402220f@news.sunrise.ch:
> > > > 
> > > > 
> > > > 
> > > > > 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
> > > > 
> > > > 
> > > > <url: 
> > > > http://search.cpan.org/~sherzodr/CGI-Session-3.95/Session/Tutori
> > > > al.p m#CREATING_NEW_SESSION>
> > > > 
> > > > 
> > > nothing about storing data in database ...
> > > 
> > > $SESSION = new CGI::Session( "driver:MySQL", undef,  { Handle
> > > =>$dbh}
> >>); $SESSION->store($dbh,$SESSION->id,'',"user_name	=> $username");
> > > 
> > > store now return : Can't use string
> > > ("b7f26a2095fb2ff4e11e8ae1295d767e") as an ARRAY ref while "strict
> > > refs" in use at ...
> > > 
> > > the string b7f26a2095fb2ff4e11e8ae1295d767e represent the
> > > sessionid what's wrong ?
> > 
> > 
> > You really don't read the documentation do you?
> > 
> > From the tutorial that Sinan pointed you at:
> > 
> >          @my_array = ("apple", "grapes", "melon", "casaba");
> >          $session->param("fruits", \@my_array);
> > 
> > Don't use store, use param.
> > 
> > Don't make us read the docs for you.
> > 
> > Mark
> 
> That's what I've try first it's doesn't store value key pair
> user_name $username ...

Show us your code using param.

Does it work with the File driver?

Mark


------------------------------

Date: Mon, 30 May 2005 14:14:35 +0200
From: Alexandre Jaquet <alexj@freesurf.ch>
Subject: Re: CGI::Session with MySQL Driver
Message-Id: <429b03ad$0$1156$5402220f@news.sunrise.ch>

Mark Clements a écrit :
> Alexandre Jaquet wrote:
> 
> 
>>Mark Clements a écrit :
>>
>>>Alexandre Jaquet wrote:
>>>
>>>
>>>
>>>>A. Sinan Unur a écrit :
>>>>
>>>>
>>>>>Alexandre Jaquet <alexj@freesurf.ch> wrote in
>>>>>news:429af5eb$0$1145$5402220f@news.sunrise.ch:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>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
>>>>>
>>>>>
>>>>><url: 
>>>>>http://search.cpan.org/~sherzodr/CGI-Session-3.95/Session/Tutori
>>>>>al.p m#CREATING_NEW_SESSION>
>>>>>
>>>>>
>>>>nothing about storing data in database ...
>>>>
>>>>$SESSION = new CGI::Session( "driver:MySQL", undef,  { Handle
>>>>=>$dbh}
>>>>); $SESSION->store($dbh,$SESSION->id,'',"user_name	=> $username");
>>>>
>>>>store now return : Can't use string
>>>>("b7f26a2095fb2ff4e11e8ae1295d767e") as an ARRAY ref while "strict
>>>>refs" in use at ...
>>>>
>>>>the string b7f26a2095fb2ff4e11e8ae1295d767e represent the
>>>>sessionid what's wrong ?
>>>
>>>
>>>You really don't read the documentation do you?
>>>
>>>From the tutorial that Sinan pointed you at:
>>>
>>>         @my_array = ("apple", "grapes", "melon", "casaba");
>>>         $session->param("fruits", \@my_array);
>>>
>>>Don't use store, use param.
>>>
>>>Don't make us read the docs for you.
>>>
>>>Mark
>>
>>That's what I've try first it's doesn't store value key pair
>>user_name $username ...
> 
> 
> Show us your code using param.
> 
> Does it work with the File driver?
> 
> Mark

sub login {
     my $username = param('user_name');
     my $userpassword = param('user_password');

     my ($user_name,$user_password)=sqlSelect("nom_utilisateur , 
mot_de_passe", "personne", "nom_utilisateur = '$username' AND 
mot_de_passe='$userpassword'");
     my $dir = "C:/indigoperl/apache/htdocs/recordz/";
     if ($user_name && $user_password) {  	
	$CGI::Session::MySQL::TABLE_NAME = 'session';
	my $SESSION = new CGI::Session( "driver:MySQL", undef,  { Handle => 
$dbh} );
	@my_array = ("$username");
	$SESSION->param("user_name", \@my_array);
	open (FILE, "<$dir/myaccount.html") or die "cannot open file 
$dir/myaccount.html";
	print "Content-type: text/html\n\n";
	$CGISESSID = $SESSION->id();
	while (<FILE>) {	
	    s/\$LABEL{'([\w]+)'}/$SERVER{$1}/g;
	    s/\$LANG/$lang/g;
	    s/\$ERROR{'([\w]+)'}//g;
	    s/\$VINYL{'news'}/$string/g;
	    s/\$SESSIONID/$CGISESSID/g;
	    s/\$VINYL{'search'}//g;	
	    print $_;	
	}
	close (FILE);
	
     }
     else {
#}}


------------------------------

Date: Mon, 30 May 2005 14:16:11 +0200
From: Alexandre Jaquet <alexj@freesurf.ch>
Subject: Re: CGI::Session with MySQL Driver
Message-Id: <429b040d$0$1156$5402220f@news.sunrise.ch>

Mark Clements a écrit :
> Alexandre Jaquet wrote:
> 
> 
>>Mark Clements a écrit :
>>
>>>Alexandre Jaquet wrote:
>>>
>>>
>>>
>>>>A. Sinan Unur a écrit :
>>>>
>>>>
>>>>>Alexandre Jaquet <alexj@freesurf.ch> wrote in
>>>>>news:429af5eb$0$1145$5402220f@news.sunrise.ch:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>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
>>>>>
>>>>>
>>>>><url: 
>>>>>http://search.cpan.org/~sherzodr/CGI-Session-3.95/Session/Tutori
>>>>>al.p m#CREATING_NEW_SESSION>
>>>>>
>>>>>
>>>>nothing about storing data in database ...
>>>>
>>>>$SESSION = new CGI::Session( "driver:MySQL", undef,  { Handle
>>>>=>$dbh}
>>>>); $SESSION->store($dbh,$SESSION->id,'',"user_name	=> $username");
>>>>
>>>>store now return : Can't use string
>>>>("b7f26a2095fb2ff4e11e8ae1295d767e") as an ARRAY ref while "strict
>>>>refs" in use at ...
>>>>
>>>>the string b7f26a2095fb2ff4e11e8ae1295d767e represent the
>>>>sessionid what's wrong ?
>>>
>>>
>>>You really don't read the documentation do you?
>>>
>>>From the tutorial that Sinan pointed you at:
>>>
>>>         @my_array = ("apple", "grapes", "melon", "casaba");
>>>         $session->param("fruits", \@my_array);
>>>
>>>Don't use store, use param.
>>>
>>>Don't make us read the docs for you.
>>>
>>>Mark
>>
>>That's what I've try first it's doesn't store value key pair
>>user_name $username ...
> 
> 
> Show us your code using param.
> 
> Does it work with the File driver?
> 
> Mark

With filedriver that's work


------------------------------

Date: Mon, 30 May 2005 12:20:39 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: CGI::Session with MySQL Driver
Message-Id: <Xns966654AC1B8B4asu1cornelledu@127.0.0.1>

Alexandre Jaquet <alexj@freesurf.ch> wrote in
news:429b00f5$0$1156$5402220f@news.sunrise.ch: 

> A. Sinan Unur a écrit :
>> Alexandre Jaquet <alexj@freesurf.ch> wrote in
>> news:429af5eb$0$1145$5402220f@news.sunrise.ch: 
>> 
>> 
>>>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
>> 
>> 
>> <URL:
>> http://search.cpan.org/~sherzodr/CGI-Session-
3.95/Session/Tutorial.pm#
>> CREATING_NEW_SESSION> 
>> 
> nothing about storing data in database ...

How would you know? You did not read any of the documentation.

> $SESSION = new CGI::Session( "driver:MySQL", undef,  { Handle =>$dbh}
> );     $SESSION->store($dbh,$SESSION->id,'',"user_name     =>
> $username"); 

I cannot fathom where you got the idea that you should call the store 
method on a CGI::Session object. There is no such method in the public 
interface or documentation or even the source code of CGI::Session.

Now, CGI::Session::Driver::mysql does implement a store method, as do 
all the drivers. But, that is not part of the public interface of a 
CGI::Session::Driver::DBI. In fact, you are not supposed to manipulate 
CGI::Session::Driver::DBI objects by yourself at all.

> what's wrong ?

You did not read the documentation.

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


------------------------------

Date: 30 May 2005 12:23:59 GMT
From: "Mark Clements" <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: CGI::Session with MySQL Driver
Message-Id: <429b05df$0$3128$8fcfb975@news.wanadoo.fr>

Alexandre Jaquet wrote:

> Mark Clements a écrit :
> 
> > Show us your code using param.
> > 
> > Does it work with the File driver?
> > 
> > Mark
> 
> sub login {
>      my $username = param('user_name');
>      my $userpassword = param('user_password');
> 
>      my ($user_name,$user_password)=sqlSelect("nom_utilisateur , 
> mot_de_passe", "personne", "nom_utilisateur = '$username' AND
> mot_de_passe='$userpassword'");      my $dir =
> "C:/indigoperl/apache/htdocs/recordz/";      if ($user_name &&
> $user_password) { 	$CGI::Session::MySQL::TABLE_NAME = 'session';
> 	my $SESSION = new CGI::Session( "driver:MySQL", undef,  { Handle =>
> $dbh} ); 	@my_array = ("$username");
> 	$SESSION->param("user_name", \@my_array);
> 	open (FILE, "<$dir/myaccount.html") or die "cannot open file
> $dir/myaccount.html"; 	print "Content-type: text/html\n\n";
> 	$CGISESSID = $SESSION->id();
> 	while (<FILE>) {	
> 	    s/\$LABEL{'([\w]+)'}/$SERVER{$1}/g;
> 	    s/\$LANG/$lang/g;
> 	    s/\$ERROR{'([\w]+)'}//g;
> 	    s/\$VINYL{'news'}/$string/g;
> 	    s/\$SESSIONID/$CGISESSID/g;
> 	    s/\$VINYL{'search'}//g;	
> 	    print $_;	
> 	}
> 	close (FILE);
> 	
>      }
>      else {
> #}}

You need to learn to partition your problem. There is a load of gumpf
here that gets in the way of the issue that you are having and makes it
more difficult for both you and us to find a solution. You've indicated
this works with the File driver, but you haven't shown us the error
message or unexpected behaviour you get with the code above.

Remember to run with strict turned on - I don't think you have with the
code above. Break down the code into the smallest number of lines that
exhibit the behaviour you are trying to demonstrate (you have been
asked to do this on other occasions). I'm not going to write the test
script for you myself.

Mark





------------------------------

Date: Mon, 30 May 2005 14:47:01 +0200
From: Alexandre Jaquet <alexj@freesurf.ch>
Subject: Re: CGI::Session with MySQL Driver
Message-Id: <429b0b47$0$1156$5402220f@news.sunrise.ch>

Mark Clements a écrit :
> Alexandre Jaquet wrote:
> 
> 
>>Mark Clements a écrit :
>>
>>
>>>Show us your code using param.
>>>
>>>Does it work with the File driver?
>>>
>>>Mark
>>
>>sub login {
>>     my $username = param('user_name');
>>     my $userpassword = param('user_password');
>>
>>     my ($user_name,$user_password)=sqlSelect("nom_utilisateur , 
>>mot_de_passe", "personne", "nom_utilisateur = '$username' AND
>>mot_de_passe='$userpassword'");      my $dir =
>>"C:/indigoperl/apache/htdocs/recordz/";      if ($user_name &&
>>$user_password) { 	$CGI::Session::MySQL::TABLE_NAME = 'session';
>>	my $SESSION = new CGI::Session( "driver:MySQL", undef,  { Handle =>
>>$dbh} ); 	@my_array = ("$username");
>>	$SESSION->param("user_name", \@my_array);
>>	open (FILE, "<$dir/myaccount.html") or die "cannot open file
>>$dir/myaccount.html"; 	print "Content-type: text/html\n\n";
>>	$CGISESSID = $SESSION->id();
>>	while (<FILE>) {	
>>	    s/\$LABEL{'([\w]+)'}/$SERVER{$1}/g;
>>	    s/\$LANG/$lang/g;
>>	    s/\$ERROR{'([\w]+)'}//g;
>>	    s/\$VINYL{'news'}/$string/g;
>>	    s/\$SESSIONID/$CGISESSID/g;
>>	    s/\$VINYL{'search'}//g;	
>>	    print $_;	
>>	}
>>	close (FILE);
>>	
>>     }
>>     else {
>>#}}
> 
> 
> You need to learn to partition your problem. There is a load of gumpf
> here that gets in the way of the issue that you are having and makes it
> more difficult for both you and us to find a solution. You've indicated
> this works with the File driver, but you haven't shown us the error
> message or unexpected behaviour you get with the code above.
> 
> Remember to run with strict turned on - I don't think you have with the
> code above. Break down the code into the smallest number of lines that
> exhibit the behaviour you are trying to demonstrate (you have been
> asked to do this on other occasions). I'm not going to write the test
> script for you myself.
> 
> Mark
> 
> 
> 


Here a complete test script :

#!perl -w
use CGI qw(:standard);
use Switch;
use CGI::Session qw/-ip-match/;
use vars qw($dbh $session);
use DBI;
use strict;

my $query ;

$dbh ||= sqlConnect("DBI:mysql:recordz:localhost", "alexj", "xxx");

execute ();


sub execute {
$query = new CGI ;
     my $action = $query->param('action');
     if ($action) {
	switch ($action) {
	    case "login" {
		login();
		};
	    case "test" {
                 };
     }
     }
}

sub login {
     $session = new CGI::Session( "driver:MySQL", undef,  { Handle => 
$dbh} );
     my $username = "alexj";
     $session->param("user_name", $username);
     my $id = $session->id;
     print "Content-type: text/html\n\n";
     print "ID : $id";
}

sub sqlConnect {
	my $dbname = shift || '';
	my $dbusername = shift || '';
	my $dbpassword = shift || '';

	$dbh = DBI->connect($dbname, $dbusername, $dbpassword);
	if (!$dbh) {
	}
	kill 9, $$ unless $dbh;
}



------------------------------

Date: Mon, 30 May 2005 14:53:14 +0200
From: Fabian Pilkowski <pilkowsk@informatik.uni-marburg.de>
Subject: Re: CGI::Session with MySQL Driver
Message-Id: <3g0gk1Fa02i1U1@individual.net>

* Alexandre Jaquet schrieb:

> Mark Clements a écrit :
>> Alexandre Jaquet wrote:
>>> Mark Clements a écrit :
>>>> Alexandre Jaquet wrote:
>>>>>
>>>>> $SESSION = new CGI::Session( "driver:MySQL", undef,  { Handle=>$dbh} );
>>>>> $SESSION->store($dbh,$SESSION->id,'',"user_name => $username");
>>>>
>>>> Don't use store, use param.
>>>
>>> That's what I've try first it's doesn't store value key pair
>>> user_name $username ...
>> 
>> Show us your code using param.

> 
> sub login {
>      my $username = param('user_name');
>      my $userpassword = param('user_password');

[...]

> 	$CGI::Session::MySQL::TABLE_NAME = 'session';
> 	my $SESSION = new CGI::Session( "driver:MySQL", undef, {Handle => $dbh} );
> 	@my_array = ("$username");
> 	$SESSION->param("user_name", \@my_array);

This creates a new session since the second param to new() is undef. The
param()-call should set the value for "user_name" in *this* session. It
seems to be all right.

How do you verify that this value is not saved in your session? Do you
look into the database by hand, don't you?

I assume your problem is to get back this session instead of creating a
new one each time your script is called. Could this be?

regards,
fabian


------------------------------

Date: Mon, 30 May 2005 14:56:02 +0200
From: Alexandre Jaquet <alexj@freesurf.ch>
Subject: Re: CGI::Session with MySQL Driver
Message-Id: <429b0d64$0$1156$5402220f@news.sunrise.ch>

Fabian Pilkowski a écrit :
> * Alexandre Jaquet schrieb:
> 
> 
>>Mark Clements a écrit :
>>
>>>Alexandre Jaquet wrote:
>>>
>>>>Mark Clements a écrit :
>>>>
>>>>>Alexandre Jaquet wrote:
>>>>>
>>>>>>$SESSION = new CGI::Session( "driver:MySQL", undef,  { Handle=>$dbh} );
>>>>>>$SESSION->store($dbh,$SESSION->id,'',"user_name => $username");
>>>>>
>>>>>Don't use store, use param.
>>>>
>>>>That's what I've try first it's doesn't store value key pair
>>>>user_name $username ...
>>>
>>>Show us your code using param.
> 
> 
>>sub login {
>>     my $username = param('user_name');
>>     my $userpassword = param('user_password');
> 
> 
> [...]
> 
> 
>>	$CGI::Session::MySQL::TABLE_NAME = 'session';
>>	my $SESSION = new CGI::Session( "driver:MySQL", undef, {Handle => $dbh} );
>>	@my_array = ("$username");
>>	$SESSION->param("user_name", \@my_array);
> 
> 
> This creates a new session since the second param to new() is undef. The
> param()-call should set the value for "user_name" in *this* session. It
> seems to be all right.
> 
> How do you verify that this value is not saved in your session? Do you
> look into the database by hand, don't you?
> 
> I assume your problem is to get back this session instead of creating a
> new one each time your script is called. Could this be?
> 
> regards,
> fabian

hi fabian, yes I look it by doing a sqlquery to verify, but the field 
user_name is alway empty

first I want to make my datas persistent into the db then I will check 
out if exising session can be reopended


------------------------------

Date: 30 May 2005 12:58:05 GMT
From: "Mark Clements" <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: CGI::Session with MySQL Driver
Message-Id: <429b0ddb$0$11680$8fcfb975@news.wanadoo.fr>

Alexandre Jaquet wrote:

> Mark Clements a écrit :
> > Alexandre Jaquet wrote:
> > 
> > 
> > > Mark Clements a écrit :
> > > 
> > > 
> > > > Show us your code using param.
> > > > 
> > > > Does it work with the File driver?
> > > > 
> > > > Mark
> > > 
> > > sub login {
> >>     my $username = param('user_name');
> >>     my $userpassword = param('user_password');
> > > 
> >>     my ($user_name,$user_password)=sqlSelect("nom_utilisateur , 
> > > mot_de_passe", "personne", "nom_utilisateur = '$username' AND
> > > mot_de_passe='$userpassword'");      my $dir =
> > > "C:/indigoperl/apache/htdocs/recordz/";      if ($user_name &&
> > > $user_password) { 	$CGI::Session::MySQL::TABLE_NAME = 'session';
> > > 	my $SESSION = new CGI::Session( "driver:MySQL", undef,  { Handle =>
> > > $dbh} ); 	@my_array = ("$username");
> > > 	$SESSION->param("user_name", \@my_array);
> > > 	open (FILE, "<$dir/myaccount.html") or die "cannot open file
> > > $dir/myaccount.html"; 	print "Content-type: text/html\n\n";
> > > 	$CGISESSID = $SESSION->id();
> > > 	while (<FILE>) {	
> > > 	    s/\$LABEL{'([\w]+)'}/$SERVER{$1}/g;
> > > 	    s/\$LANG/$lang/g;
> > > 	    s/\$ERROR{'([\w]+)'}//g;
> > > 	    s/\$VINYL{'news'}/$string/g;
> > > 	    s/\$SESSIONID/$CGISESSID/g;
> > > 	    s/\$VINYL{'search'}//g;	
> > > 	    print $_;	
> > > 	}
> > > 	close (FILE);
> > > 	
> >>     }
> >>     else {
> > > #}}
> > 
> > 
> > You need to learn to partition your problem. There is a load of gumpf
> > here that gets in the way of the issue that you are having and makes it
> > more difficult for both you and us to find a solution. You've indicated
> > this works with the File driver, but you haven't shown us the error
> > message or unexpected behaviour you get with the code above.
> > 
> > Remember to run with strict turned on - I don't think you have with the
> > code above. Break down the code into the smallest number of lines that
> > exhibit the behaviour you are trying to demonstrate (you have been
> > asked to do this on other occasions). I'm not going to write the test
> > script for you myself.
> > 
> > Mark
> > 
> > 
> > 
> 
> 
> Here a complete test script :
> 
> #!perl -w
> use CGI qw(:standard);
> use Switch;
> use CGI::Session qw/-ip-match/;
> use vars qw($dbh $session);
> use DBI;
> use strict;
> 
> my $query ;
> 
> $dbh ||= sqlConnect("DBI:mysql:recordz:localhost", "alexj", "xxx");
> 
> execute ();
> 
> 
> sub execute {
> $query = new CGI ;
>      my $action = $query->param('action');
>      if ($action) {
> 	switch ($action) {
> 	    case "login" {
> 		login();
> 		};
> 	    case "test" {
>                  };
>      }
>      }
> }
> 
> sub login {
>      $session = new CGI::Session( "driver:MySQL", undef,  { Handle => 
> $dbh} );
>      my $username = "alexj";
>      $session->param("user_name", $username);
>      my $id = $session->id;
>      print "Content-type: text/html\n\n";
>      print "ID : $id";
> }
> 
> sub sqlConnect {
> 	my $dbname = shift || '';
> 	my $dbusername = shift || '';
> 	my $dbpassword = shift || '';
> 
> 	$dbh = DBI->connect($dbname, $dbusername, $dbpassword);
> 	if (!$dbh) {
> 	}
> 	kill 9, $$ unless $dbh;
> }

OK - this is better but you still don't quite get it. I'm not exactly sure what
your problem is at the moment (you haven't stated it clearly, despite repeated
prompting): is it that CGI::Session fails with an error message, or that you don't
get anything in the database table? To save time, and my hair, we need to see
something like:

use strict;
use warnings;

use CGI::Session qw/-ip-match/;
use DBI;

my $dbname = "dbname";
my $dbusername = "dbusername";
my $dbpassword = "dbpassword";

my $dbh = DBI->connect($dbname, $dbusername, $dbpassword) 
	or die "could not open db connection - error = $DBI::errstr";

my $session = 
		CGI::Session->new( "driver:MySQL", undef,  { Handle => $dbh} );

$session->param( testkey => "testdata" );

print "stored session with id " . $session->id();

You can then check in the db table directly to see if the session has been stored.
I will leave it as an exercise to you to come up with a minimal script to pull
sessions out again.

Once the above is working properly, you can experiment with more complex data
structures and wiring it back into your cgi script.


>sub sqlConnect {
>	my $dbname = shift || '';
>	my $dbusername = shift || '';
>	my $dbpassword = shift || '';
>
>	$dbh = DBI->connect($dbname, $dbusername, $dbpassword);
>	if (!$dbh) {
>	}
>	kill 9, $$ unless $dbh;
>}

kill? bit harsh, plus you have no idea what the error is. You want

die $DBI::errstr unless $dbh;


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 8130
***************************************


home help back first fref pref prev next nref lref last post