How to? Override login cookie format+content (to support legacy app)

A few years back I began to migrate to yii2 from an legacy system.
At the time I never quite got the webUser Interace class quite right.

Years have gone by, and now this is an issue I must fix. In miminal time with minimal upset of course.

I think the core issue is that yii2 wants to specify/control the format and content of the cookie.
In my case, the legacy app has that control and I cannot change it.

Here is the fix that works for me. \legacyCookieGetUserId() invokes the old sytem to get an id from the cookie.
And everything else falls into place.

PROBLEM: This routine is protected. I can’t override it. I would have to bring this kludge forward with every upgrade.

It seems to me the same problem exists with getIdentityAndDurationFromCookie() (it is protected). That may be the better place to override, but I have not tested it.

The legacy system handles login/logout and manages the cookie format. I may not change it. I only need Yii2 to know when a user is logged in.

Is there a slicker way to hack into web User? Is there something else I am not thinking of ?

Is it reasonable for yii2 to support a custom cookie content format, should I ask for it ?

FILE: vendor/yiisoft/yii2/web/User.php

/**
 * User is the class for the `user` application component that manages the user authentication status.
 *
 ...
class User extends Component
{
		...
    protected function renewAuthStatus()
    {
        $session = Yii::$app->getSession();
        $id = $session->getHasSessionId() || $session->getIsActive() ? $session->get($this->idParam) : null;

        /*
         * HACK ALERT! 
				 * dsm 19 dec 20
         * Get user_id from cookie. This solves my "lost login" problem with Yii2 frontend. 
         */
        $id  = \legacyCookieGetUserId();

        ...
    }

You can override protected functions.

Good lord I am thick sometimes!
This is what happens to people who try coding after the age of 65.
Many thanks.

Hahaha
No problem at all! At least you are putting your brain to work. Hope to be doing it at your age.

If you happen to get a solution, please share with others here.