Page 1 of 1

Session handling and redirection different under Xitami?

Posted: Wed Jul 02, 2003 2:13 pm
by Jean-Yves
Hi,

Just copied all my php scripts to my new WinXP Home PC running Xitami as the web server. Previously I was developing under Win2000 Pro/IIS and deploying on RedHat/Apache (don't ask!)

Now, sessions don't seem to work under Xitami in the same way as the other platforms. For example, I get the following error:

Undefined index: user

Whenever accessing a page that has the following code at the specified line:

$currentUser = $_SESSION["user"];

Now, in this case the session has not been set, but under the other platforms $currentUser would therefore be "false" and I check for this later.

Second and more worrying:
I don't seem to be able to perform redirection to relative paths. ie:

header("location:login.php"); //does not work
header("http://localhost/login.php"); //does work

The former works fine on my IIS and Apache systems.

Full spec:
WinXp Home SR-1
PHP 4.3.2
Xitami 2.5b5 (Service)
MySQL 4.01 (should be irrelevant)

Please help as I'm tearing my hair out here and my wife would prefer me not to go bald just yet! ;)

Posted: Thu Jul 03, 2003 3:27 am
by twigletmac
That notice will be occuring on all platforms, you just haven't seen it before because you've not had your error reporting at the highest level. To set $user to false if $_SESSION['user'] does not exist you can do:

Code: Select all

$user = (!empty($_SESSION['user'])) ? $_SESSION['user'] : false;
This will prevent the undefined index notice from appearing when you try and access the unset element.

Mac

Posted: Thu Jul 03, 2003 7:25 am
by Jean-Yves
Hi Mac, many thanks for reply. The message no longer pops up now that I'm checking for a null session.

What's odd is that I have installed 4.3.2 on my Win2000 PC and that was *not* reporting the error. Strange.

Now, if anyone can solve the relative path redirection problem as well, then I'll be a very, very happy boy indeed :)

JY

Posted: Thu Jul 03, 2003 10:10 am
by Jean-Yves
As a test, I installed Xitami on my Win2000 PC. The redirection problem occurs on this PC too. So it does seem as though it is Xitami rather than PHP.

Here is the Xitami defaults.cfg file:

Code: Select all

#*END

їSecurity]
    Filename=defaults.aut

їServer]
    Default3=index.php

їFilter]
    .php=c:\apps\php\php.exe

їMime]
 php=application/x-httpd-php
Anyone on these boards use Xitami? Does it work for you? Please, please help!

Thanks

Posted: Fri Jul 04, 2003 3:29 am
by Jean-Yves
Success turns to failure!

Turns out that if you want Xitami and PHP to coexist happily you need to install XIFusion (Available from link on Xitami.org site). This a a small wrapper that was originally written to allow Allaire ColdFusion to use Xitami, but it now also supports PHP.

Or so it says. I installed it and *still* could not get relative path redirection.

Eventually I uninstalled both PHP and Xitami, installed Apache 1.3.27 and reinstalled PHP 4.3.2

After quite a lot of poking around inside the config files, Apache now invokes the PHP CGI module, but, wait for it, PHP 4.3.2 has a bug in it that prevents it displaying web pages correctly (or at all) as a CGI module with Apache! By this time it was midnight so I called it a day. Tonight I shall try PHP 4.3.1.

I am learning a lot about configuring web servers though ;)

Posted: Sun Jul 06, 2003 3:30 pm
by Jean-Yves
Just to finally wrap up this thread... PHP 4.3.1 works fine with Apache.
Finally I can get on with my code. :)