hi ,

I am new to perl .I have a query regarding accessing stored session .Kindly pls help :

here is my firstpage.pl
#!/usr/bin/perl -w use strict; use DBI; use CGI qw/:all :html3/; use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; use CGI::Session qw(); my $session = CGI::Session->new(); print $cgi->header; print $session->header; print "<html><head>"; print "</head>"; print "<body>"; # here are the values from the HTML form my $username = param('username'); my $password = param('password'); my $groups; my $dbh=DBI->connect('DBI:mysql:database=:host=:user=root') || die "Co +uld not connect to database: ". DBI->errstr; my $query = "select user,password,groups from login_ro where user li +ke '$username' and password like '$password' "; my $sth=$dbh->prepare($query) or die "Couldnt prepare statement:" .$db +h->errstr; $sth->execute(); if(($username,$password,$groups)= $sth->fetchrow_array) { chomp($username); chomp($password); chomp($groups); print "<meta http-equiv=\"refresh\ +" content=\"0; url=./dashboard_status.pl?groups=$groups\" />"; print "<input type=hidden name=\"u +sername\" value=\"$username\">"; $session->param("ro", $groups); $session->param("user", $username +); $session->param(User_id => 'U0000 +2'); my $regional_office = $session->p +aram("ro"); print "$regional_office"; my $tmp=$session->param("User_id" +); print "$tmp"; } else { print "<meta http-equiv=\"refresh\" content=\"0; url=. +/errlogin.pl\" />"; } # print bottom of page print <<HTML; </body> </html> HTML
this is my second.pl page:
#!/usr/bin/perl -w use strict; use warnings; use DBI; use CGI qw/:all :html3/; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use CGI::Session qw(); use sub test(); my $cgi = new CGI; print "<html><head>"; my $session = CGI::Session->new((undef, $cgi, {Directory=>"/tmp"})); $session = CGI::Session->new(); print $session->header; my $dbh=DBI->connect('DBI:mysql:database=:user=root;host=') || die "Co +uld not connect to database: ". DBI->errstr; my $group = param('groups'); my $atmcount; my $regional_office = $session->param('ro'); ///here is am ac +cesing stored session my $tmp= $session->param('User_id'); print "regional--->$regional_office"; my $user = $session->param('user');
but I am not able to access the stored session .Kindly please help .

In reply to reg access of stored session variable by amithublikar

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.