Thursday, 24 June 2021

cookie vs session vs client side cache vs server side cache

Cookie VS Session

    Session and cookie both store user level data, session store at server side, cookie store at client side

SESSIONS ENDS WHEN USER CLOSES THEIR BROWSER,

COOKIES END DEPENDING ON THE LIFETIME YOU SET FOR IT. SO THEY CAN LAST FOR YEARS

This is the major difference in your choice,

If you want the id to be remembered for long time, then you need to use cookies; otherwise if you just want the website to recognize the user for this visit only then sessions is the way to go.

Sessions are stored in a file your php server will generate. To remember which file is for which user, php will also set a cookie on the user's browser that holds this session file id so in their next visit php will read this file and reload the session.

https://stackoverflow.com/questions/6253633/cookies-vs-sessions


Server side session vs server side cache 


Session data is stored at the user level but caching data is stored at the application level and shared by all the users. Sessions may not improve performance whereas Cache will improve site performance. Items in cache can expire after given time to cache while items in session will stay till session expires.

  1. Session data is stored at the user level but caching data is stored at the application level and shared by all the users.

  2. Sessions may not improve performance whereas Cache will improve site performance.

  3. Items in cache can expire after given time to cache while items in session will stay till session expires.

http://net-informations.com/faq/asp/caching.htm#:~:text=Session%20data%20is%20stored%20at,will%20stay%20till%20session%20expires.



Client side cookie vs client side cache

The main difference between Cache and Cookie is that, Cache is used to store online page resources during a browser for the long run purpose or to decrease the loading time. On the other hand, cookies are employed to store user choices such as browsing session to trace the user preferences.


https://www.geeksforgeeks.org/difference-between-cache-and-cookies/#:~:text=The%20main%20difference%20between%20Cache,to%20trace%20the%20user%20preferences.



No comments:

Post a Comment