Home > Back-end >  How to test api with session in django
How to test api with session in django

Time:09-11

I am currently building an auth app that provides register, login, logout ... functionalities. Everything seems to work fine, however when I log the user in, I cannot logout, I get an Anonymous user error instead. After searching on the internet I came to the conclusion that it is not the best to build an api with sessions and instead to use tokens(JWT). With sessions I cannot test my API with tools like POSTMAN because that requires cookies (technically you can use cookies in POSTMAN though). Having said that, sessions seem to be more stable and secure so how would I go about testing my API using the sessions stored in the cookie? Thanks.

CodePudding user response:

Postman supports using cookies. when you enable it you can access it through scripts. write a script for you login and logout to set cookies ( if it wasn't updated automatically)

you can read more about it here.

  • Related