specialtactics / laravel-api-boilerplate

Laravel API Boilerplate | Quickly build quality API products!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

session id changes with every request

sunder6218 opened this issue · comments

Hey, i have been building my api system on top of your boilerplate, which saved me a huge amount of time, but im having trouble after authentication, the AUTH works fine and i get the token in response, but in my API i have set a session variable and its active only for that request , in the consequent request the session is flushed out and i get a different token in response. i have enabled Sessions in API middleware, and and set the session domain.

the session seems to retain when i make the request through postman, but not when i use axios or guzzle. and i can see the session files created in storage folder with different token

array:2 [
  "_token" => "JpRUe19KiVojlXvnahHSgcsJmbI8Cj4zb9FP1kEE"
  "use_company" => 1
]

[
"_token" => "OzfWDpUykwt0OnASz627e7o3C7LtlYgONTs6qqiH"
]

commented

Hi @sunder6218 - REST is supposed to be stateless - it does not make any sense to have a "session" with the consumers of your API, because there is no reliable way to track it, and the whole concept of REST APIs is that they are not meant to have sessions with the client.

commented

Closed due to no response.

Hi @sunder6218 - REST is supposed to be stateless - it does not make any sense to have a "session" with the consumers of your API, because there is no reliable way to track it, and the whole concept of REST APIs is that they are not meant to have sessions with the client.

Thank you , i have changed the approach accordingly to better suit the API.