Thanks for reply but i just find out if i run my code as http://localhost/cgi-bin/script.pl, cookie function work. my file is accessed by SSI. but this way there is no cookie. I dont know either it is script or my apache server. thanks
#!/usr/bin/perl -w use strict; use CGI; use DBI; use Template; use CGI::Ajax; use CGI::Session; use CGI::Cookie; use CGI::Session::Driver::mysql; use CGI::Carp qw(fatalsToBrowser); my ($src, $lib, $files); #print "Content-type:text/html\n\n"; my $cgi = CGI->new(); my $ip = $cgi->remote_host(); my $sid = $cgi->cookie("CGISESSID") || undef; my $os = $^O; if($os =~ /MSWin32/){ $src = 'D:/mixedapache/cgies/templatetoolkit/src'; $lib = 'D:/mixedapache/cgies/templatetoolkit/lib'; $files = 'D:/mixedapache/cgies/templatetoolkit/'; }else{ $src = '/mnt/win_d/mixedapache/cgies/templatetoolkit/src'; $lib = '/mnt/win_d/mixedapache/cgies/templatetoolkit/lib'; $files = '/mnt/win_d/mixedapache/cgies/templatetoolkit/'; } my $dbh = DBI->connect('dbi:mysql:phones', 'name', 'password', {RaiseE +rror =>1}); my $session = CGI::Session->new('driver:mysql', $sid, { TableNAme => 'sessions', IdColNAme => 'id', DataColName=> 'a_session', Handle => $dbh, }) or die CGI::Session->errstr; my $cookie = $cgi->new(-name => $session->name, -value => $session->id +); print $session->header(); my $config = { INCLUDE_PATH => [ $src, $lib, $files, ] }; my $tt = Template->new($config); my $url ='/cgi-bin/ajax.pl'; my $ajaxbit = CGI::Ajax->new( 'external' => $url, 'login' => \&login, 'skip_header' => 1, ); $ajaxbit->skip_header(1); print $ajaxbit->build_html($cgi, \&mainpage); sub mainpage{ my $output = ''; my $vars = { }; my $input = 'perltemp'; $tt->process($input, $vars, \$output) || die $tt->error( ); return $output; }

In reply to CGI SESSION Cookies and SSI help by seekperlwisdom

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.