Hi,
I have copied the following Perl CGI code from internet and modefied the same to hold values in the session.

But I donot have any idea about the procedure to retrieve the values from session. Kindly help me.

The code of first page is as follows and I need help with code for second page to retrive values from session.

#!/usr/bin/perl -w use DBI; use CGI::Session; use CGI; my $db_name="aa"; my $db_host="bb"; my $db_user="cc"; my $db_pass="dd"; print "Content-Type: text/html\n\n"; $dbh = DBI->connect("DBI:mysql:database=$db_name; host=$db_host", "$db_user","$db_pass", {PrintError => 1, RaiseError => + 1, AutoCommit => 1}); my $cgi = new CGI; my $sid = $cgi->cookie('SessionId') || $cgi->param('SessionId') || und +ef; my $session = new CGI::Session("driver:MySQL;<br>id:MD5", undef, {Hand +le=>$dbh}); print "session : $session "; if ( $session->is_expired ) { print "Your session is expired. Please Login"; } else { print "Session is not expired"; } if (!$sid) { print "No Session Exists. Please Login"; } #Active Session; if ($session_user && $session_pass) { print "Username and Password are present"; } elsif (!$session_user || !$session_pass) { #Account Error. Username or Password not present. Please Login } $session->expire(1800); print "Session ID : $session->id "; $cookie = $cgi->cookie(SessionId => $session->id ); print $cgi->header(-cookie=>$cookie); $x=$cgi->cookie('SessionId'); $session->param('username', "myname"); $y=$session->param('username'); print "From Session : $y"; $name=$session->param('SessionId'); print "Value from Session : $x "; $session->save_param(); $dbh->disconnect(); print "<form name=testsession method=post action='def.cgi'>"; print "<input type=submit value=submit> </form>"; exit;



Thanks in advance for any help.
Regards,
Ramesh.

Edit: g0n - code tags


In reply to How to retrive value from session using Perl CGI. by ramesh_ps1

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.