...

View Full Version : sessions annoying me now.



bazz
07-08-2009, 01:27 AM
Hi,

can't seem to make my session consistent from page to page :mad:

If I refresh this one page (as shown below), it still changes the session_id each page load.



#!/usr/bin/perl


use CGI;
use DBI;
use strict;
use CGI qw(escapeHTML);
use CGI::Carp qw(fatalsToBrowser);
use CGI::Session;

my $cgi = new CGI;

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



So much at a totla loss, I can't even think what question to ask other than;
what must I do to make sessions work.

bazz

bazz
07-08-2009, 02:04 AM
I have removed all other code from the file by writing it like this.

Still, it won't hold to one session.



#!/usr/bin/perl


use CGI;
use DBI;
use strict;
use CGI qw(escapeHTML);
use CGI::Carp qw(fatalsToBrowser);
use CGI::Session;

my $cgi = new CGI;

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

print $session->header;
print $cgi->header;
print $session->dump;
print qq( $session_id );


exit;



Yet this script will



#!/usr/bin/perl

use CGI;
use CGI::Carp qw(fatalsToBrowser);
use strict;
use DBI;
use Date::Manip;
use CGI::Session;
use POSIX;
my $cgi = new CGI;
use Date::Parse;
use Date::Format;
use Data::Dumper;

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

print $session->header;
print qq( sess_id = $session_id <br />);



bazz

netroact
07-09-2009, 04:55 AM
Maybe I'm missing something here, but it displays the same session_id when I l refresh the page. It adds some more poop after the first refresh, but the session_id stays the same. I can even switch back and forth between both scripts, and it keeps the same session_id, as long as I don't close the browser.

bazz
07-09-2009, 03:09 PM
It doesn't with me.

ON first page load is creates a session. On second page load it creates a new session which remains persistent until the browsaer is closed. As to why it won't create a persistent connection from the first page , I have no ideas.

If it works perfectly on your machine does that point to me having a server issue?

bazz

bazz
07-09-2009, 03:48 PM
OK, when I go straight to the page, the session loads and is persistent.

If, however, I click a link from an outside site to the same page, the session is set (but not persistent), until I have clicked to get to a second page in the session-testing site. If I simply refresh page1 of the site, the session id changes every time.

is this how sessions are meant to work? why does persistency behave differently, when arriving at the page in two different ways?

bazz

netroact
07-10-2009, 04:10 AM
I made a link from another website to the session script. It created a session_id. When I refreshed the browser, it kept the exact same session_id.
I also tried a link from the same website that hosts the script. Same result.

I don't think it could be a server issue, since it creates a session and a cookie. I thought it might be a browser issue, but I tried it in IE and FF with the same result.

Are all other tabs and browser windows closed when attemping the test?

bazz
07-10-2009, 04:29 AM
very curious.

I have rewritten the script and it works. However, when I reverted to the one which has caused me trouble - didn't work, it now works too.

No idea why but I suppose, now that it is working, it's all ticketyboo.

bazz



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum