Hi All,
I'm struggling with a session problem and I'm not sure where I should be
looking for the answer.
Most of my pages begin like this:
====================================
include_once('cfheader.php');
$feedback = cfHeader("Main Page");
//Start of page code
====================================
The cfheader.php file begins like this:
====================================
<?PHP
session_start();
function cfHeader($Title,$Protect=false)
{
$feedback="";
//IF we're loggin on then destory and get new session
if (IsSet($_POST['login']))
{
include_once('userreg.inc');
session_destroy(); //Destroy current session before continuing
$feedback =do_login();
}
if ($Protect==true && !IsSet($_SESSION['name']))
{
//No Session.
echo "<META HTTP-EQUIV='refresh' content='2;URL=mypage.php'>"; //Redirect
exit;
}
====================================
This works fine on my development PC, (PHP v 4.3.1) and on my primary test
site (PHP v4.2.2).
However when I try it on the target site (PHP v4.1.2) then I find that
immediately after starting the session everything works fine, however when I
move to any other page the session information is lost and I'm redirected to
log in again.
I was looking over the PHPInfo but to be honest I can't see what it is
that's different.
All help is gratefully appreciated.
regards,
Dave
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.497 / Virus Database: 296 - Release Date: 04/07/2003
You need to make sure that when you are being directed to the other pages that the session
name and session id are being passed. Check session.use_trans_sid in the sessions section
of phpinfo(). The session name and id are available globally after a session has been
started as the constant SID. If you are posting form data, make sure there is an input
for the session name with a value of the session id, etc.
Hope that helps.
--
Jason k Larson
Dave Alger wrote:
> Hi All,
>
> I'm struggling with a session problem and I'm not sure where I should be
> looking for the answer.
>
> Most of my pages begin like this:
> ====================================
>
> include_once('cfheader.php');
> $feedback = cfHeader("Main Page");
> //Start of page code
> ====================================
> The cfheader.php file begins like this:
>
> ====================================
> <?PHP
> session_start();
> function cfHeader($Title,$Protect=false)
> {
> $feedback="";
> //IF we're loggin on then destory and get new session
> if (IsSet($_POST['login']))
> {
> include_once('userreg.inc');
> session_destroy(); //Destroy current session before continuing
> $feedback =do_login();
> }
> if ($Protect==true && !IsSet($_SESSION['name']))
> {
> //No Session.
> echo "<META HTTP-EQUIV='refresh' content='2;URL=mypage.php'>"; //Redirect
> exit;
> }
> ====================================
>
>
> This works fine on my development PC, (PHP v 4.3.1) and on my primary test
> site (PHP v4.2.2).
> However when I try it on the target site (PHP v4.1.2) then I find that
> immediately after starting the session everything works fine, however when I
> move to any other page the session information is lost and I'm redirected to
> log in again.
>
> I was looking over the PHPInfo but to be honest I can't see what it is
> that's different.
>
> All help is gratefully appreciated.
>
> regards,
> Dave
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.497 / Virus Database: 296 - Release Date: 04/07/2003
>
>
>
Thanks to all who posted.
Well, I managed to track down the problem. The PHP system was set to use
/tmp for its session.save_path but there was no /tmp directiory.
Strange because on my test site I don't have a /tmp directory... I'm
guessing my ISP has taken care of that separately.
Anyway I created a tmp folder and everything seems fine.
Thanks again.
Dave
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.497 / Virus Database: 296 - Release Date: 04/07/2003