I run app on google cloud platform using php in standard mode.
I use session_set_save_handler
to store session in mysql database.
.php file
...
$mysqli = new mysqli($config->host, $config->user, $config->password, $config->db, $port, $socket);
// test connection, works fine.
$mysqli->query("INSERT INTO `sessions` (`ID`, `SessionID`, `Data`, `DateTouched`) VALUES (NULL, 'aaa1', 'aa1', '21')");
$CurrentTime = time();
function sess_open($sess_path, $sess_name) {
echo "session open - sess_path: " . $sess_path . "session_name " . $sess_name . "<br />";
return true;
}
function sess_close() {
echo "session close" . "<br />";
return true;
}
...
function sess_write($sess_id, $data) {
GLOBAL $mysqli;
echo 'session write';// never called
$CurrentTime = time();
$mysqli->query("UPDATE sessions SET Data = '$data', DateTouched = $CurrentTime WHERE SessionID = '$sess_id';");
return true;
}
...
session_set_save_handler("sess_open", "sess_close", "sess_read", "sess_write", "sess_destroy", "sess_gc");
session_start();
$_SESSION['foo'] = "bar";
$_SESSION['baz'] = "wombat";
$s_w_c = session_write_close();
var_export($s_w_c); // false on gcloud
It works fine on my local system(MAMP), but the write function is not called on google. Other functions works fine. Any idea?
Thanks.