Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Client only cookies - cookie which doesn't ever go to the server

I want to store user-clicked data in a cookie which never has to go to the server. Its like a session-added data, which I want to persist over sessions, as in the data just keeps adding to the cookie, and it is stored for a long time, and only gets deleted when the user removes browsing history. The cookie is pure-client only cookie and it never has to go the server, as I don't need the user generated data at the server, so I want to get rid of the additional overhead the cookie creates in sending back and forth between browser and server. Is it possible to achieve this?

like image 622
Siva Bathula Avatar asked Jun 18 '12 12:06

Siva Bathula


People also ask

Are cookies sent from client to server?

Cookies are sent by the browser to the server when an HTTP request starts, and they are sent back from the server, which can edit their content. Cookies are essentially used to store a session id. In the past cookies were used to store various types of data, since there was no alternative.

What is the difference between server side cookie and client side cookie?

There is no difference. A regular cookie can be set server side or client side. The 'classic' cookie will be sent back with each request. A cookie that is set by the server, will be sent to the client in a response.

Can cookies be accessed by client side?

Cookies can only be read by the website the domain that creates them; you can use sub-domains domains, url paths. Cookies are generally considered insecure if used from the client side, and should not be used to hold sensitive data if accessed from the client side.

Are cookies only stored locally?

If you're wondering “where are cookies stored,” it's simple: your web browser will store it locally to remember the “name-value pair” that identifies you. If a user returns to that site in the future, the web browser returns that data to the web server in the form of a cookie.


1 Answers

I know it´s a little late for you, but this answer is for all who have the same problem.

1) With HTML5 you can use [web storage][1].

2) (Just an idea! - not tested!) You could define a cookie (via javascript on client) and set the "secure"-attribute. In this case, the cookie will only be sent to the server on HTTPS connections. To make sure the cookie never leaves the browser, you just never open a HTTPS connection ;-)

like image 187
Franz Deschler Avatar answered Sep 29 '22 12:09

Franz Deschler