session_regenerate_id example

if (null !== $lifetime && $lifetime != \ini_get('session.cookie_lifetime')) {
            $this->save();
            ini_set('session.cookie_lifetime', $lifetime);
            $this->start();
        }

        if ($destroy) {
            $this->metadataBag->stampNew();
        }

        return session_regenerate_id($destroy);
    }

    /** * @return void */
    public function save()
    {
        // Store a copy so we can restore the bags in case the session was not left empty         $session = $_SESSION;

        foreach ($this->bags as $bag) {
            
if (null !== $lifetime && $lifetime != \ini_get('session.cookie_lifetime')) {
            $this->save();
            ini_set('session.cookie_lifetime', $lifetime);
            $this->start();
        }

        if ($destroy) {
            $this->metadataBag->stampNew();
        }

        return session_regenerate_id($destroy);
    }

    /** * @return void */
    public function save()
    {
        // Store a copy so we can restore the bags in case the session was not left empty         $session = $_SESSION;

        foreach ($this->bags as $bag) {
            

    }

    /** * Regenerates the session ID. * * @param bool $destroy Should old session data be destroyed? */
    public function regenerate(bool $destroy = false)
    {
        $_SESSION['__ci_last_regenerate'] = Time::now()->getTimestamp();
        session_regenerate_id($destroy);

        $this->removeOldSessionCookie();
    }

    private function removeOldSessionCookie(): void
    {
        $response              = Services::response();
        $cookieStoreInResponse = $response->getCookieStore();

        if ($cookieStoreInResponse->has($this->config->cookieName)) {
            return;
        }
<?php
require __DIR__.'/common.inc';

session_set_save_handler(new TestSessionHandler('abc|i:123;'), false);
session_start();

session_regenerate_id(true);

ob_start(fn ($buffer) => str_replace(session_id(), 'random_session_id', $buffer));
Home | Imprint | This part of the site doesn't use cookies.