Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning: session_regenerate_id(): Session object destruction failed in

Tags:

php

session

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

like image 667
lmorse Avatar asked Nov 26 '22 18:11

lmorse


2 Answers

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

like image 111
Lars Moelleken Avatar answered Dec 05 '22 00:12

Lars Moelleken


I encountered the same problem and resolved it by updating Read and Write permissions to the folder as described here at github. Hope it helps someone.

like image 21
Phemelo Khetho Avatar answered Dec 04 '22 23:12

Phemelo Khetho