views:

162

answers:

0

I have a very strange problem.
Situation: Session handling over MySQL, PHP 5.2.4, wildcard cookies, FF/Opera/Safari/Chrome works, IE7/8 not.

When I save a variable into the session, the value is lost. The DB shows after the write action only "N" instead of "123456".
Example:

$bar = 123456;
$_SESSION['foo'] = $bar;

But when I save a constant in the session, it works.

$_SESSION['foo'] = 123456;

This is not really a client problem, but only in IE it doesn't work.
Any ideas?

Edit:
This is the session write function:

function _write($id, $data) {

    $write = "UPDATE session SET time='".time()."', data='".mysql_real_escape_string($data)."' WHERE id='".mysql_real_escape_string($id)."'";
    $result = @mysql_query($write);
    if(mysql_affected_rows()) return $result;
    else {
        $write = "INSERT INTO session (id, time, data) VALUES ('".mysql_real_escape_string($id)."', '".time()."', '".mysql_real_escape_string($data)."')";
        return @mysql_query($write);
    }
}

When I print the update query ($write) everything looks fine. I can execute the SQL manually and it works, also with variables.