When logged in using loginWithCookie how do I go to Dashboard

I am using
$userSession->loginWithCookie($user, $token, $session);

I then check if user was successfully logged with
$ok=$userSession->isLoggedIn();
and I get a true.

Now I would like to go to Dashboard? How do I do that?

Now I would like to go to Dashboard? How do I do that?

The URLGenerator followed by a RedirectResponse may be what you’re looking for.

See either the the Dev Manual[1] (and server code repo). Might also get some ideas from looking at the LoginController (in server)

What are you working on?

[1] https://docs.nextcloud.com