Why my session is invalid?

I have this method “login”, the method login the user its simple to understand.
when i login it works and it printed to me the user and response.

async login ({ request, auth, response }) { 

      const { email, password } = request.all();
        const isLogeddin = await auth.check()
        const user = await auth.getUser()
          response.status(401).send({ alert: 'User already logged in!',  user})
          await auth.attempt(email, password)
          const user = await auth.getUser()
          response.status(200).send({ message : 'Sucessfully Logged in!', user })
          response.status(401).send({ error: 'Credentials Invalid!' })

But, when i access logout method, i get:

E_INVALID_SESSION: Invalid session

My logout method for test.

async logout({ request, response, auth}) {
      const test = await auth.check()

async show({request, response, auth}){

   const user = await auth.getUser()

   return user


Whats going on if i can get auth.getUser() in login but i cant get it in logout?

The debug output always give to me something like that when access logout method:

adonis:middlewarebase executing NaN server middleware +0ms
adonis:middlewarebase executing 6 global and named middleware +13ms


'use strict'

const providers = [

const aceProviders = [


const aliases = {
  Role: 'Adonis/Acl/Role',
  Permission: 'Adonis/Acl/Permission',

const commands = []

module.exports = { providers, aceProviders, aliases, commands }


'use strict'

/** @type {import('@adonisjs/framework/src/Server')} */

const Server = use('Server')

const globalMiddleware = [







const namedMiddleware = {

auth: 'Adonis/Middleware/Auth',

guest: 'Adonis/Middleware/AllowGuestOnly',

is: 'Adonis/Acl/Is',

can: 'Adonis/Acl/Can',


const serverMiddleware = [

// 'Adonis/Middleware/Static',








'use strict'

const Route = use('Route')


Route.post('/logout', 'SessionController.logout').middleware('auth')

Route.post('/login', 'SessionController.login')

When I log in by route /login, it works normally, and when I’m logged in, I access /user, it gives me back the user as expected in controller.

But when I access the logout method it gives me an invalid session error, I can’t understand


Are you sure session cookie is attached to logout request?


Hi, how to make this?