What are cookies and how are they commonly used on an ecommerce website?
I thought I’d have a look at the cookies on asos.com (I’m using the “Edit my cookie” extension for Chrome)
A lot of stuff in here!
Some of it’s pretty hard to interpret, but a few cookies like:
Are pretty easy to recognise and understand.
As an experiment, I tried changing the browseCountry from NZ to AU…
Now it presents me with the asos AU homepage! (hard to prove, but here's some subtle evidence):
My shopping bag has one item in it, and there is a cookie called asosbasket.
I thought maybe I could play with that cookie - and change the basketitemcount - but apparently not.
That information must be getting correctly refreshed from the server side.
But I *can* change this value in local storage - and it updates the UI.
(With no real effect, there’s still only one item in my cart - fun to play with though.
This led into an interesting conversation with my team about cookies v local storage, and when you’d use one or the other.
Cookies should be used when the server needs the value for some reason - cookies are sent to the server as part of the web request.
Local storage doesn’t get sent to the server - it’s just for client side work.
The feedback I got was that Local Storage is preferred when there’s nothing to send to the server, because
- there’s a dictionary to work with - cookies you’re just scanning through a giant string
- local storage can hold much more information than a cookie
So - there you go! Not sure I really completed the task, but I learned something so ¯\_(ツ)_/¯