Può essere uno dei seguenti:
- Archiviazione nel database e associazione dei percorsi URL alle query del database
- Archiviazione su un file e associazione dei percorsi URL ai nomi di file
- Archiviazione in memoria e mappatura dei percorsi URL alle strutture dati
In termini di design dell'URL, è senza stato:
Imagine a shop where rather than being self-service, there is a shopkeeper who upon being asked, goes and fetches the items you want and rings them up on the till. Now if we were to model that as our online shop we'd see that the client no longer has a basket as part of their state, the basket is part of the shop.
So how would this work? Looking at the interactions between the client and the server, it might look something like this:
Client
Show me your products.
Server
Here's a list of all the products you can buy at this shop.
Client
Good, okay, I'd like to buy 1 of http://example.org/shop/product/X, please place it in my basket, my username is "JohnDoe" and my password is "secretPassword".
Server
Okay, I've added 1 of http://example.org/shop/product/X into your basket, you can review your basket at http://example.org/shop/users/johndoe/basket
Client
I'd like to buy 1 of http://example.org/shop/product/Y as well, please place one in my basket, my username is "JohnDoe" and my password is "secretPassword".
Server
Okay, I've added 1 of http://example.org/shop/product/Y into your basket as well, you can still review your basket at http://example.org/shop/users/johndoe/basket
Client
Actually I don't want http://example.org/shop/product/X after all, please remove it from my cart, my username is "JohnDoe" and my password is "secretPassword".
Server
Okay, I've removed http://example.org/shop/product/X from your basket, you can review your updated basket at http://example.org/shop/users/johndoe/basket
Client
Okay I'm done, ring 'em up, my username is "JohnDoe" and my password is "secretPassword".
Server
Should I charge that to your expense account?
The thing to notice about this conversation is that it is stateless, every action from the client is independent of any other. This means that at any time, the user can run off and do something else, come back a few days later and carry on. It also means they could get some other service to add things to their shopping basket easily.
Riferimenti
Vivere senza sessioni