public function setName($name): void
    {
        if ($this->sessionExists()) {
            throw new SessionException(
                'Cannot set session name after a session has already started'
            );
        }

        if (!preg_match('/^[a-zA-Z0-9]+$/', $name)) {
            throw new SessionException(
                'Name provided contains invalid characters; must be alphanumeric only'
            );
        }

        $this->name = $name;
        session_name($name);
    }
public function setName($name): void
    {
        if ($this->sessionExists()) {
            throw new SessionException(
                'Cannot set session name after a session has already started'
            );
        }

        if (!preg_match('/^[a-zA-Z0-9]+$/', $name)) {
            throw new SessionException(
                'Name provided contains invalid characters; must be alphanumeric only'
            );
        }

        $this->name = $name;
        session_name($name);
    }
public function setName ( $ name ) : void { if ( $ this -> sessionExists ( ) ) { throw new SessionException ( 'Cannot set session name after a session has already started' ) ; } if ( ! preg_match ( '/^[a-zA-Z0-9]+$/' , $ name ) ) { throw new SessionException ( 'Name provided contains invalid characters; must be alphanumeric only' ) ; } $ this -> name = $ name ; session_name ( $ name ) ; }
Attempt to set the session name

If the session has already been started, or if the name provided fails
validation, an exception will be raised.

@param  string $name

@throws SessionException
@return void
Attempt to set the session name