Hi, All, I am newer on Mason.

I have a question about : how to initial the session variable in Mason
component.

I use CGI::Cookie and Apache::Session::MySQL for that.

don't care I use which Cookie package,

I can make it work, in my example code.
like this: ( file name: li1.html )

Hi, this is way for test the session
<% $session{_session_id} %><br>

<%init>

use CGI::Cookie;
use Apache::Session::MySQL;

local %session;

my %cookie = fetch CGI::Cookie;

if ( $cookie{'MASONSESSIONID'} ) {
    tie %session,
    "Apache::Session::MySQL", $cookie{'MASONSESSIONID'}->value, {
        DataSource=>'dbi:mysql:database=5acity;host=localhost',
        UserName=>'root',
        Password=>'',
        LockDataSource=>'dbi:mysql:database=5acity;host=localhost',
        LockUserName=>'root',
        LockPassword=>''
    };
} else {
    tie %session, 'Apache::Session::MySQL', undef, {
        DataSource=>'dbi:mysql:database=5acity;host=localhost',
        UserName=>'root',
        Password=>'',
        LockDataSource=>'dbi:mysql:database=5acity;host=localhost',
        LockUserName=>'root',
        LockPassword=>''
    };

    my $temp_cookie = CGI::Cookie->new(
        -name=>'MASONSESSIONID',
        -value=>$session{'_session_id'},
        -expire=>'40m',
        -domain=>'.5axinyu.com');

    $temp_cookie->bake($r);
}
</%init>


but now, I want to put these codes to autohandler in this directory:

use the the tag <%once> or <%init> too.
but I can't use the variable in li1.html.

it said:
*error:*  Error during compilation of
/home/ghw/myperl/5axinyu/html/li1.html:
syntax error at /home/ghw/myperl/5axinyu/html/li1.html line 5, near
"PARENT:"

 *context:*   *1:*  Hi, this is way for test the session  *2:*  <%
$session{_session_id} %><br>  *3:*
 *4:*  <%init>  *5:*  my %session = PARENT:session;  *6:*  </%init>  *7:*
   *code stack:*
/usr/local/lib/perl5/site_perl/5.10.0/HTML/Mason/Interp.pm:445
/usr/local/lib/perl5/site_perl/5.10.0/HTML/Mason/Request.pm:246
/usr/local/lib/perl5/site_perl/5.10.0/HTML/Mason/Request.pm:211
/usr/local/lib/perl5/site_perl/5.10.0/HTML/Mason/ApacheHandler.pm:97
/usr/local/lib/perl5/site_perl/5.10.0/Class/Container.pm:275
/usr/local/lib/perl5/site_perl/5.10.0/Class/Container.pm:353
/usr/local/lib/perl5/site_perl/5.10.0/HTML/Mason/Interp.pm:348
/usr/local/lib/perl5/site_perl/5.10.0/HTML/Mason/ApacheHandler.pm:868
/usr/local/lib/perl5/site_perl/5.10.0/HTML/Mason/ApacheHandler.pm:822
(eval 30):8
-e:0
  raw error <http://www.5axinyu.com/li1.html#raw>


any suggestions?

thanks

Mike.G
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to