title: Ktor Session Cookie Authentication
body: <p>I'd like to use a session cookie for authentication with Ktor and what I have so far is:</p>
  
  <pre><code>private const val SEVER_PORT = 8082
  private const val SESSION_COOKIE_NAME = "some-cookie-name"
  
  data class AuthSession(
      val authToken: String
  )
  
  fun main() {
      embeddedServer(Netty, port = SEVER_PORT, module = Application::basicAuthApplication).start(wait = true)
  }
  
  fun Application.basicAuthApplication() {
      install(Sessions) {
          cookie&lt;AuthSession&gt;(SESSION_COOKIE_NAME, SessionStorageMemory()) {
              cookie.path = "/"
          }
      }
      install(DefaultHeaders)
      install(CallLogging)
      install(Authentication) {
          session&lt;AuthSession&gt; {
              validate { session -&gt;
                  // TODO: do the actual validation
                  null
              }
          }
      }
  
      routing {
          authenticate {
              get("/") {
                  call.respondText("Success")
              }
          }
      }
  }
  </code></pre>
  
  <p>But everytime when I do:</p>
  
  <pre><code>curl -v localhost:8082
  </code></pre>
  
  <p>I get an HTTP 200 and the response "Success"</p>
  
  <p>I expected to get an HTTP 401 Not authorized or something similar.</p>
  
  <p>Can somebody give me insights here how to do proper session cookie authentication with Ktor?</p>
  
  <p>thanks</p>