PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > PHP gives session error on remote server, but not local test machine
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
PHP gives session error on remote server, but not local test machine

Réponse
 
LinkBack Outils de la discussion
Vieux 07/04/2008, 12h10   #1
Dave M G
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut PHP gives session error on remote server, but not local test machine

PHP list,

I have a large set of PHP scripts of my own design that outputs any
errors to text log files.

These scripts are deployed on a few different sites, at different
virtual hosting services. On one, I keep seeing this error in my log files:

Error Handler message: session_start() [<a
href='function.session-start'>function.session-start</a>]: The session
id contains illegal characters, valid characters are a-z, A-Z, 0-9 and
'-,' /home/domains/mydomainname.com/public_html/index.php 107

Before I show the content of index.php, I want to emphasize that no
other virtual host produces this error. My home testing environment
doesn't either. I have doubly ensured that the scripts are the same
across all environments. So there must be something in the interaction
of my scripts on that hosting service that is causing this error.

Here are the contents of index.php, trimmed of most comments for
brevity. Line 107 is where the last session_start() call is.

My question is why would this code trip an error on one server, but not all?

Thank you for any advice.

--- code ---

include_once '+site/Settings.php';
include_once 'Global.php';
set_error_handler(array('ErrorHandler','handleErro r'), E_ALL);
// initialize the output tree. This is the structure that receives all
the ouput and stores it in a tree form
// based on the HTML structure
HTML::initializeTree();
$userRequest = trim($_SERVER['REQUEST_URI'], "/");
if (Browser::supports())
{
session_start();
}
else
{
if (strlen($userRequest) != 0)
{
$sessionArray = Session::decodeSessionID($userRequest);
if (is_array($sessionArray))
{
session_id($sessionArray[0]);
$userRequest = $sessionArray[1];
}
else
{
$userRequest = $sessionArray;
}
}
session_start();
}

--- code ends ---

--
Dave M G
Articlass - open source CMS
http://articlass.org
  Réponse avec citation
Vieux 08/04/2008, 05h15   #2
Dave M G
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] PHP gives session error on remote server, but not localtest machine [SOLVED]

PHP list,

Solving my own issue:

It turns out that some PHP scripts had an extra carriage return
character at the end of the file. Once I removed these, the problem went
away.

Strange that it only happened on some servers, not others, but there it is.

--
Dave M G
Articlass - open source CMS
http://articlass.org
  Réponse avec citation
Vieux 08/04/2008, 20h44   #3
Stut
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] PHP gives session error on remote server, but not local test machine [SOLVED]

On 8 Apr 2008, at 04:15, Dave M G wrote:
> PHP list,
>
> Solving my own issue:
>
> It turns out that some PHP scripts had an extra carriage return
> character at the end of the file. Once I removed these, the problem
> went away.
>
> Strange that it only happened on some servers, not others, but there
> it is.


1. Enable E_ALL error_reporting and turn on display_errors - that
should have told you the session could not be started because headers
had already been sent

2. Don't put ?> when it's the last thing in a file, it's not necessary
by design for this very reason

The servers where it worked probably had an implicit buffer configured
thus not caring about output before session_start().

-Stut

--
http://stut.net/
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h57.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,15290 seconds with 11 queries