1

We use POST requests when changing resources and GET when searching for resources on the server right ? I want to know exactly what do we mean with 'resources' ? is it only the data stored on the database ? Can we consider the SESSION as one of these resources ?

Let's say I'm working on a PHP server and want to modify a variable inside a session, or destroying the session for the client, without modifying anything in the database. Should i use a POST type request or a GET type request for that ?

2 Answers2

0

The HTTP methods can exist without a database behind. This names GET, POST, ..., are made for the understanding of the client. So, if the method creates, modifies, or deletes something, use POST, PUT, or DELETE (respectively) to let the client know that something is being created, modified or deleted.

Filipe Gomes
  • 189
  • 2
  • 5
0

Application State vs Resource State

Application state is server-side data which servers store to identify incoming client requests, their previous interaction details, and current context information.

Resource state is the current state of a resource on a server at any point of time and it has nothing to do with the interaction between client and server.It is what you get as a response from the server as API response. You refer to it as resource representation.

From: https://restfulapi.net/statelessness/

As For which method to use for changing Application State(session):

GET Request Should be idempotent so we cannot update/create the session with GET method.

Use GET to Get Value of Session, POST to update session, PUT to create session and Delete to delete session

Manish Chauhan
  • 167
  • 2
  • 10