On my Sitecore instance I'm authenticating a user programatically like this(adapted for this post):

 

    [HttpGet]
            public ActionResult MyAction(MyModel model)
            {
                 //custom logic
                 Sitecore.Security.Authentication.AuthenticationManager.Login("extranet\\"+username,password);
            }


This works well. When I call the `Sitecore.Context.User.IsAuthenticated` property to check whether the user was authenticated it returns true.
But that lasts until the ActionResult finishes it's execution.  When I make a post or redirect the user to another page the IsAuthenticated property always returns false.

For example I have a post which gets executed on the same page declared as:

    

        

            [HttpPost]
            public ActionResult MyAction(MyModel model, string anotherParameter)
            { 
                   //This always returns false
                   if (Sitecore.Context.User.IsAuthenticated)
                   {
                        //my custom logic. 
                   }
                    
            }

This is what my session state looks on the web.config

    <sessionState mode="InProc" cookieless="false" timeout="20" sessionIDManagerType="Sitecore.SessionManagement.ConditionalSessionIdManager">
      <providers>
        <add name="mongo" type="Sitecore.SessionProvider.MongoDB.MongoSessionStateProvider, Sitecore.SessionProvider.MongoDB" sessionType="Standard" connectionStringName="session" pollingInterval="2" compression="true" />
        <add name="mssql" type="Sitecore.SessionProvider.Sql.SqlSessionStateProvider, Sitecore.SessionProvider.Sql" sessionType="Standard" connectionStringName="session" pollingInterval="2" compression="true" />
      </providers>
    </sessionState>

As far as I can tell this is fine and should make the session last for 20 minutes.

Any thoughts on what could be wrong here?