PDA

View Full Version : session conflict? [SOLVED]


bazz
05-30-2008, 04:13 AM
I hope I can explain this OK.

In my site, I have a room bookings form on part of all pages. When I select dates and submit, script 2 loads a session and stores the data that it should.

Then I go to script three (to see more details about a room), and it also loads a session but, it has a new id. It stores what it should but it doesn't include the data from the first session.

However, if I go back to the previous page and refresh it, that script adopts the session id of the later script and merges data from the first session into the second.

Is this a known issue or have I created a new one? :)

here is the code from the start of script one

use CGI;
use CGI::Carp qw(fatalsToBrowser);
use strict;
use DBI;
use Date::Manip;
use Date::Parse;
use Date::Format;
use Data::Dumper;
use CGI::Session;
use POSIX;

my $cgi = new CGI;

use lib '/var/www/vhosts/mydomain/subdomains/hotel/cgi-bin/';
require 'header_control.pm'; # locate headers and footers module

my $session = CGI::Session->load($cgi) or die CGI::Session->errstr;
#my $session_id = $session->param('_SESSION_ID');

and here's the start of the code from script 2


use CGI;
use CGI::Carp qw(fatalsToBrowser);
use strict;
use DBI;
use Date::Manip;
use POSIX;
use Data::Dumper;
use CGI::Session;

my $cgi = new CGI;
use lib '/var/www/vhosts/mydomain/subdomains/hotel/cgi-bin/';

require 'header_control.pm'; # locate headers and footers module

my $session = CGI::Session->load($cgi) or die CGI::Session->errstr;
Can anyone suggest what is going on please and how I might fix it.

bazz

FishMonger
05-30-2008, 05:42 AM
Sounds like the problem might be in the 3rd script. Can you post the beginning of it?

bazz
05-30-2008, 01:37 PM
Sorry FishMonger, I confused myself.

The second and third scripts do use the same session as indicated when is use


print $session->header;


however, a dump of script 2, shows the session id to be 'undef'. Once i get to script 3, it is defined as being that shown for script 2.

I guess that something is wrong with the starting of the session in script 2. I'll try other things again and re-read a much leaved-through cpan manual/tutorial.

If you/anyone can offer any tips, I would be very pleased.

bazz

bazz
05-30-2008, 02:34 PM
Got it solved.

I moved the session parts of the script, out of the header and into the actual script.

bazz