What is the distinct difference between session_id($randomString)
and session_regenerate_id()
? Both seem to change session id:
in a way session_regenarate_id()
includes session_id()
internally.
session_id()
is a way to get or set the session identifier. It doesn't handle sessionsess_*
files. You place it beforesession_start
in order to indicate the session identifier. Cookie creation and session file creation aresession_start
work later on.
On the other hand
session_regenarate_id()
is something that does not simply set the session identifier but also get your session data from the oldsess_*
file and append it to the new one (with the random id) and create a newcookie
. Depending on thedelete_old_session
parameter insession_regenarate_id()
if set totrue
it will delete the old associated session file, otherwise it will remain as a file but it will be empty of all session data.