Local Storage vs Session Storage vs Cookies for Frontend Devs

𝗠𝗮𝗷𝗼𝗿𝗶𝘁𝘆 𝗼𝗳 𝗱𝗲𝘃𝗲𝗹𝗼𝗽𝗲𝗿𝘀 𝘂𝘀𝗲 𝗮𝗹𝗹 𝘁𝗵𝗿𝗲𝗲… yet somehow get confused. 𝗦𝗲𝘀𝘀𝗶𝗼𝗻 𝗦𝘁𝗼𝗿𝗮𝗴𝗲, 𝗟𝗼𝗰𝗮𝗹 𝗦𝘁𝗼𝗿𝗮𝗴𝗲 & 𝗖𝗼𝗼𝗸𝗶𝗲𝘀… explained in simple terms 👇 You should definitely know what happens with your information as a frontend developer. 𝗦𝗲𝘀𝘀𝗶𝗼𝗻 𝗦𝘁𝗼𝗿𝗮𝗴𝗲 • Lasts only during that session/tab  • Disappears once the tab is closed  • Good for storing temporary information 𝗟𝗼𝗰𝗮𝗹 𝗦𝘁𝗼𝗿𝗮𝗴𝗲 • Does not disappear even when browser is closed/reopened  • Does not expire unless manually cleared out  • Ideal for storing user preferences 𝗖𝗼𝗼𝗸𝗶𝗲𝘀 • Attached to every HTTP request  • May have expiration date attached  • Commonly used for authentication, sessions and other purposes  • Limited in capacity 𝗘𝗮𝘀𝘆 𝘁𝗼 𝗿𝗲𝗺𝗲𝗺𝗯𝗲𝗿: Local = permanently Session = temporarily Cookies =  stored in browser + automatically sent to server 𝗜𝗺𝗽𝗼𝗿𝘁𝗮𝗻𝘁 𝗻𝗼𝘁𝗲: Avoid storing any sensitive information in local storage (token/credentials/etc.) as it will lead to breaches. When developing real applications, using one of those can ruin user experience. Which mistake did you make while using them before? 👇 #WebDevlopment #JavaScript #Frontend #MERN #100DaysofCode #Developers

To view or add a comment, sign in

Explore content categories