www.webdeveloper.com
+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2006
    Posts
    93

    PHP5 Session_Start error, PHP4 was ok.

    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.

    Does anybody know how to fix this problem?

    Cheers,
    Nap

  2. #2
    Join Date
    Dec 2006
    Location
    Escazú (Costa Rica) and Mallorca (Spain)
    Posts
    3,234
    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...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



Recent Articles