Php – Warning: session_regenerate_id(): Session object destruction failed in

PHPsession

I am receiving the following error randomly when going through the session login code; Warning: session_regenerate_id(): Session object destruction failed in…,

I am using WAMP with PHP5.5.12 on Windows 8.1 Pro 64 bit

$session_name = 'seam_secure_session_id';
ini_set('session.use_only_cookies', 1);
$cookieParams = session_get_cookie_params();
session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"], $cookieParams["domain"], $secure, $httponly);
session_name($session_name);
session_start();

session_regenerate_id(true);// regenerated the session, delete the old one.

ob_start();

I receive no other session warnings or errors, and the login code is called at the start of my code before any HTML. I have checked php.ini and the session.save_path. Permissions are fine (Authenticated users, SYSTEM, admin, User all have full control) on the save path, the sessions files are being saved in the folder.

I am at a loss, any ideas?

Thanks

Lee

Best Answer

I think you see the warning because "session_regenerate_id(true)" tries to delete the old session, but the session maybe isn't written at this point. PHP will write the session-file at the end of the script, at the mean time the session values are only in memory. This is also the reason why we use session_write_close or exit after a header redirect, so that the session is written already at this point.

Maybe you can check if the session is available before you try to delete it? e.g.: https://github.com/yiisoft/yii/commit/45d6a7d51be2ea12a935a94511290cb9670706d9

Related Topic