Skip to content

regenSession

Corey Avis edited this page Sep 23, 2026 · 2 revisions

regenSession

Regenerates the current session ID. This should be called during state/privilege changes (e.g., post-login) to protect against session fixation attacks.

Usage

regenSession(bool $deleteOldSession = true): bool

Parameters

deleteOldSession (bool) : Whether to delete the old associative session file/data. (default: true) ^(optional)^

Return Value

(bool) : Returns true on success, or false if no active session exists.

Examples

// User completes login process
if ($userAuthenticated) {
    $cphp->regenSession();
    $cphp->setSession('logged_in', true);
}

Debug Errors

  • No debug errors.

Related Methods

clearSession | endSession | getSession | removeSession | setSession | startSession


Home | CoreyPHP | Session Management

Clone this wiki locally