|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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/ |
|
![]() |
| Outils de la discussion | |
|
|