Hi Guys,
My site was just moved from a server running PHP 4.4.4 to a server running PHP 5.2.0. And all of a sudden I'm getting errors to do with the session_start() function.
Here is a code snippet of the page, it is directly accessed by users.
(note this is the start of the code and there are no spaces etc sent to the ob_buffer in advance)
PHP Code:
<?php
session_start();
$tblprefix = $_GET['comp'];
$page = "login";
require('./../variables.php');
require('./../variablesdb.php');
require('./../top.php');
?>
<p class="header">Admin section.</p>
<?
$sql="SELECT * FROM $admintable WHERE name = '$_POST[username]' AND password = '$_POST[password]'";
$result=mysql_query($sql,$db);
$number = mysql_num_rows($result);
if ($number == "1") {
session_register("password");
session_register("username");
}
if($_SESSION[username]){
?>
...
With PHP 5.2.0, the above code produces the following errors (all interwoven):
Code:
Warning: session_start() [function.session-start]: The session id contains illegal characters,
valid characters are a-z, A-Z, 0-9 and '-,'
in /home/b1034/public_html/fc/competitions/Admin/index.php on line 2
Warning: session_start() [function.session-start]: Cannot send session cookie -
headers already sent by (output started at /home/b1034/public_html/fc/competitions/Admin/index.php:2)
in /home/b1034/public_html/fc/competitions/Admin/index.php on line 2
Warning: session_start() [function.session-start]: Cannot send session cache limiter -
headers already sent (output started at /home/b1034/public_html/fc/competitions/Admin/index.php:2)
in /home/b1034/public_html/fc/competitions/Admin/index.php on line 2
I do not assign a value to the session_id variable anywhere, so I can't understand why there are illegal characters there in the first place.
I deleted my cookie for the domain, hoping that might have something to do with it but it didn't change anything.
I've looked at the PHP.NET site but haven't found any explainations on what needs to be done in PHP5 that differs from PHP4.
I have read something being said about session.save_path. On my PHP4 server, it was set to /tmp, but on my PHP5 server it's not set.
You could print the session id with session_id() and see what comes up. Worst casing it, you could probably set it yourself. Not the most elegant solution to the problem, agreed, but better than the site being off-line...
Bookmarks