title: Overloaded method error in Scala Play Framework
body: <p>I am writing a method to set the session cookie properly after a user authenticates. Setting the cookies as follows does not work. The following snippet results in an error with the 'withSession' call:</p>
  
  <p><strong>Overloaded method value [withSession] cannot be applied to ((String, Long))</strong></p>
  
  <p>Code:</p>
  
  <pre><code>/**
   * Process login form submission.
   */
  def authenticate = Action { implicit request =&gt;
    loginForm.bindFromRequest.fold(
      formWithErrors =&gt; BadRequest(views.html.login(formWithErrors)),
      credentials =&gt; {
        val user = models.User.findByEmail(credentials._1)
  
        user match {
          case Some(u) =&gt; {
            Redirect(routes.Dashboard.index).withSession(Security.username -&gt; u.id)
          }
          case None =&gt; Redirect(routes.Auth.login)
        }
      }
    )
  }
  </code></pre>
  
  <p>'credentials' is simply a tuple with the email and password submitted by the user. If I get rid of 'withSession' part then it runs fine. If I move the 'Redirect' statement out of the pattern matching code then is works fine. Why does it not work as I have it above and how do I fix it?</p>