Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners Cgi > Problem in Sess...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 1434 of 1478
Post > Topic >>

Problem in Session Accessing

by visitprakashindia@[EMAIL PROTECTED] (Praki) Dec 11, 2007 at 08:02 AM

Greetings All,

i m creating a session storing the loging credentials. i want to
access that data later after crossing two pages.i have created the
sesion but i could not get the data back some where i m going wrong
can u point me where ..


my first first file getting the login credentials


#!/usr/local/bin/perl5
&top();
&login_check();
&bottom();
sub top{
print <<EOM1;
Content-type: text/html


<html>
  <head>
    <title>Login Authentication</title>
  </head>
<body>
EOM1


}


sub bottom{
print <<EOM2;
</body>
</html>
EOM2

}


sub login_check{
print <<EOM;
<h3>Enter the login Password</h3>
<form  method="post" action="cookie.cgi">
<input type="hidden" name="username"  value='Submit'>
<p>Username: <input type="text" name="uid" size="20"></p>
<p>Password: <input type="password" name="passwd" size="20"></p>
<input type="submit" value="Submit" name="submit">
</form>
EOM


}


second file where i m creating the session.

#!/usr/local/bin/perl5
use Net::LDAP;
&top();
&login_check();
&bottom();


sub top{
  print <<EOM1;
Content-type: text/html


<html>
  <head>
    <title>Login Authentication</title>
  </head>
<body>
EOM1


}


sub bottom{
  print <<EOM2;
</body>
</html>
EOM2

}


sub login_check{
  my ($ret);
  use CGI;
  my $query = new CGI;
  $query->param("submit");
  my $userid = $query->param("uid");
  my $password = $query->param("passwd");
use CGI;
use CGI::Session;

$session = new CGI::Session("driver:File",undef,{'Directory'=>"/
tmp"});
$sid = $session->id();
print "Session id:".$sid;


#$session->name($userid);
# Write the session variable on the server
$session->param('username',$userid);
$session->param('password',$password);
print "username:".$userid."pass:";


$usernam = $session->param('username');
$passwor = $session->param('password');


print "username from the cookie:".$usernam;


#create session cookie
$cookie = $query->cookie(CGISESSID => $session->id);
print $query->header( -cookie=>$cookie );
#print "cookie:".$cookie;
   print <<EOM;
      <h5>Cookie created  <a href="/cgi-bin/sesion/cookie/
test.cgi">click here to check</a> </h5>
EOM



}


Third file to access the session values.

#!/usr/local/bin/perl5
&top();
&cookie_check();
&bottom();
sub top{
print <<EOM1;
Content-type: text/html


<html>
  <head>
    <title>Login Authentication</title>
  </head>
<body>
EOM1


}


sub bottom{
print <<EOM2;
</body>
</html>
EOM2

}


sub cookie_check{
use CGI;
use CGI::Session;
my $query = new CGI;

$sid = $query->cookie('CGISESSID') || $query->param('CGISESSID') ||
undef;
$session = new CGI::Session(undef, $sid, {Directory=>'/tmp'});
$username = $session->param('username');
$password = $session->param('password');


print <<EOM;
<h3>Cookie test  $username $password</h3>
EOM



}


i m not getting the values when  i read here. i dont know where the
cookie is created. i check with the server i  could see the session
which is created in the server.please tell me where i m going
wrong.....

thanks in advance..
Prakash
 




 1 Posts in Topic:
Problem in Session Accessing
visitprakashindia@[EMAIL   2007-12-11 08:02:49 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 19:01:58 CDT 2008.