amithublikar has asked for the wisdom of the Perl Monks concerning the following question:
I am new to perl .I have a query regarding accessing stored session .Kindly pls help :
here is my firstpage.plthis is my second.pl page:#!/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
but I am not able to access the stored session .Kindly please help .#!/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');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: reg access of stored session variable
by CountZero (Bishop) on Nov 11, 2013 at 11:23 UTC | |
|
Re: reg access of stored session variable
by hippo (Archbishop) on Nov 11, 2013 at 11:29 UTC | |
|
Re: reg access of stored session variable
by Mr. Muskrat (Canon) on Nov 11, 2013 at 16:21 UTC | |
|
Re: reg access of stored session variable
by Anonymous Monk on Nov 11, 2013 at 23:22 UTC |