473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

problem loading session

rajiv07
141 100+
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
4 2034
KevinADC
4,059 Expert 2GB
where is $cgi defined?

$session = new CGI::Session("driver:File", $cgi, {Directory=>'/tmp'});
Jun 11 '07 #2
miller
1,089 Expert 1GB
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
141 100+
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
141 100+
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

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

Similar topics

1
by: Chip | last post by:
I am trying to get sessions to work on a log in screen to give certain users access to certain pages/directories. The problem is that when the login button is pushed (or the enter key pressed) the...
3
by: Fran García | last post by:
I´ve a big problem with the session variables. I load audio files into media player using as src a php script that check some session variables and then load the audio file, something like that ...
8
by: Ashish | last post by:
Incase the problem got bogged down reposting... Hi Gregory, I think I didnt make myself much clear. The problem is: 1. I have one ASP.NET application (no classic asp) and it has a main page...
5
by: matthew | last post by:
Hi all, I am now writing a aspx that get a session variable (string) and then write it out using Response.Write. The string length is: 494710. But Response.Write only write the string...
1
by: Kris van der Mast | last post by:
Hi, been a while since I posted a question myself instead of trying to help others out. I'm refactoring an existing web app that uses dynamic loading of user controls and a lot of...
5
by: Mikko Penkkimäki | last post by:
Hi Looks like I can not change Web page's timeout setting. In practise it's all the time 20 minutes - no matter what I do. I have this kind of setting in web.config: <sessionState...
2
by: ven | last post by:
Hello i have a dynamic datatable in my page. I wanna to write data to textboxes and after click on button "ADD data" i want to refresh datagrid on page... Here is my code : ' Insert page code...
7
by: jsale | last post by:
I'm currently using ASP.NET with VS2003 and SQL Server 2003. The ASP.NET app i have made is running on IIS v6 and consists of a number of pages that allow the user to read information from the...
3
by: =?Utf-8?B?a3lvbmc=?= | last post by:
hey, i'm trying to figure out how i would load items to the session after the reponse has been sent out. (1) so user goes to /default.aspx (2) server does it's thing and sends response back...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.