-1

This may look like standard problem, but it isn't. I'm getting this error:

session_start() [function.session-start]: Cannot send session cache limiter

....and that's what I just can't understand, because session_start() is first thing written in the file (except <?php). This is the code:

<?php

    session_start();

    include "config.php";

    $escapedName = mysql_real_escape_string($_GET['email']);
    $escapedPW = mysql_real_escape_string($_GET['password']);

    $query ="SELECT salt FROM users WHERE email='".$escapedName."'";
    $result = mysql_query($query, $link) or die ("SQL dotaz sa nepodaril");
    $num = mysql_num_rows($result);

    while ($row=mysql_fetch_array($result)){
        $salt = $row["salt"];
    }

    $saltedPW =  $escapedPW . $salt;
    $hashedPW = hash('sha256', $saltedPW);

    //echo $hashedPW."<br>";

    $query ="SELECT ESN_WINGS_ID as id FROM users WHERE email='".$escapedName."' AND password='".$hashedPW."'";
    $result = mysql_query($query, $link) or die ("SQL dotaz sa nepodaril");
    $num = mysql_num_rows($result);

    if($num == 0)
        echo "Invalid e-mail or password";

    while ($row=mysql_fetch_array($result)){
        $_SESSION["id"] = $row["id"];
        echo $SESSION["id"]."NOT WORKING!";
        //echo $row["id"];
    }

?>

Thank You for responses.

James
  • 4,644
  • 5
  • 37
  • 48

1 Answers1

0

"This may look like standard problem, but it isn't".

Most times when people say that, it IS a standard problem they just say that because they cannot find the issue from reading others' resolves to the "standard" issue. (I've been there)

You have to call session_start() before anything else. It's that simple. While PHP errors and warnings can sometimes be misleading, not point to the exact issue (just the next thing that was affected by the issue) etc, it is usually pretty logical and, importantly, "means what is says!"

If it tells you headers already sent, then headers are already sent. Either a space or return carriage (although this is not usually enough to cause the issue), some text, etc.

I tried copy/paste your code and using your top part with session_start() it worked fine for me. So I'm thinking you might have UTF-8 with BOM (I do not have BOM).

Make sure there are no spaces above, before or next to your <?php and it's right at the very top of the file, and make sure session_start() is right underneath your <?php and make sure there are no spaces or extra return carriages between them, then test.

If this still fails, look at http://en.wikipedia.org/wiki/Byte_order_mark. If your editor is set to encode with BOM, try setting it to encode without BOM.

Also, make sure your editor doesn't have some weird setup for space/tab, it might be adding undesired chars instead of the standard ones.

James
  • 4,644
  • 5
  • 37
  • 48