By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,971 Members | 1,732 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,971 IT Pros & Developers. It's quick & easy.

problem loading session

rajiv07
100+
P: 141
Expand|Select|Wrap|Line Numbers
  1. use CGI;
  2. use DBI;
  3. use CGI::Session;
  4. use CGI::Cookie;
  5. use CGI::Carp qw(fatalsToBrowser);
  6.  
  7. my $q = new CGI;
  8.  
  9. my $c = new CGI::Cookie;
  10.  
  11. my $session = "" ;
  12.  
  13. my $sid = "" ;
  14. if ($sid eq "") {
  15.     $session = new CGI::Session("driver:File", $cgi, {Directory=>'/tmp'});
  16.     my $server = $ENV{'HTTP_HOST'} ;
  17.     my $path = "/";
  18.     $sid = $session->id() ;
  19.     print "Set-Cookie: CGISESSID\=$sid; path\=$path; domain\=$server\n" ;
  20.  
  21. } else {
  22.     $session = new CGI::Session(undef, $sid, {Directory=>'/tmp'});
  23. }
  24.  
  25.  
  26. my $cUser = $session->param("user");
  27.  
  28. if ($cUser eq "") {
  29.     $cUser = $sid;
  30. }
  31.  
  32. $session->param("id", $sid);
  33.  
  34. #
  35.  
  36. if (($cAmount eq "") && ($cQty eq "") && ($cAction eq "") && ($aAmount eq "")) {
  37.     my $cTempFile="../buyegv/templates/buygc_temp.html";
  38.     my $cTemplate=_ReadFile($cTempFile);
  39.  
  40.     $cTemplate=~ s/__CURRENCY__/$cCurrency/ig;
  41.  
  42.     print "Content-type: text/html\n\n";
  43.     print $cTemplate;
  44.     exit;
  45. }
  46.  
  47.  
  48. if (($cAction eq "calculate") && ($aAmount eq "")) {
  49.     my $cTotalPrice = $cAmount*$cQty;
  50.     my $cGc="BuyGc";
  51.     $session->param("amount",$cTotalPrice);
  52.     $session->param("buygc",$cGc);
  53.     #$session->param("id",$sid);
  54.     $session->expires("+12h");
  55. }
  56.  

Here when i run this script first time it's running,but after session id is store
again i run this script it wii give session error like "cannot locate session here"

please help me
thank u
Jun 11 '07 #1
Share this Question
Share on Google+
4 Replies


KevinADC
Expert 2.5K+
P: 4,059
where is $cgi defined?

$session = new CGI::Session("driver:File", $cgi, {Directory=>'/tmp'});
Jun 11 '07 #2

miller
Expert 100+
P: 1,089
Kevin is right. $cgi is probably a typo of $c.

I strongly encourage you to add the strict pragma to the beginning of all of your scripts. That would have caught that simple mistake. You're already doing a good job by defining all of your variables with "my", so let perl help you out.

Expand|Select|Wrap|Line Numbers
  1. use strict;
  2.  
- Miller
Jun 12 '07 #3

rajiv07
100+
P: 141
Hi,
After i defined $cgi like
my $cgi=new CGI;

also it gives the same error

please help me.
thank u.
Jun 12 '07 #4

rajiv07
100+
P: 141
use CGI;
use CGI::Session;
use CGI::Cookie;

my $cgi=new CGI;
my $c=new CGI::Cookie;

$sid = _CheckCookie1();

if($sid eq "")
{
$session = new CGI::Session("driver:File", $cgi, {Directory=>'/tmp'});

my $server = $ENV{'HTTP_HOST'} ;

my $path = "/";

$sid = $session->id() ;

print "Set-Cookie: CGISESSID\=$sid; path\=$path; domain\=$server\n" ;
}
else
{
$session = new CGI::Session(undef, $sid, {Directory=>'/tmp'});
}
$session->param("id", $sid);
$session->expire('+12h');
Problem In Session

Is Anythig i have to modify above code
please help me
thank U.
Jun 14 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.