Create a custom login using OktaAuth

I have made a login component which accepts an email and password to authenticate users and am using OktaAuth and its SignIn flow to authenticate and get the session token. However, redirecting to a secure route redirects to the Okta sign in widget and authState.isAuthenticated is also false. Here is the code snippet:

      password: this.state.password
    .then(res => {
      session_token: res.sessionToken,
      authenticated: true

and in my render method:

if (this.state.authenticated) {
      // this.oktaAuth.session.setCookieAndRedirect(this.state.session_token, "/");
      this.props.authService.redirect("/home" +, {sessionToken: this.state.session_token, email:});
      return null;

/home/email is a protected route. I want to know how I can redirect to it after pressing the login button which triggers the first snippet of code.

it’s shown in the doc signing

on SUCCESS you do setCookieAndRedirect

I tried using setCookieAndRedirect(seesionToken, “/home/email”) but it redirects me to Okta hosted sign in page