{"id":8852,"date":"2025-04-26T16:50:58","date_gmt":"2025-04-26T11:20:58","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=8852"},"modified":"2026-11-03T12:11:54","modified_gmt":"2026-11-03T06:41:54","slug":"understanding-javascript-cookies","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/understanding-javascript-cookies\/","title":{"rendered":"JavaScript Cookies: How to Set, Get, and Delete Cookies"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong><strong>Post Date:<\/strong><\/strong> April 26, 2025<strong><br><strong>Last Updated:<\/strong> <\/strong>November 03, 2026<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/devdocs.io\/javascript\/\" target=\"_blank\" rel=\"noopener\">JavaScript<\/a> cookies are small pieces of data stored in a user&#8217;s web browser that help websites remember information between visits. They are commonly used to manage user sessions, store user preferences, remember login information, and provide a personalized browsing experience.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">JavaScript provides the <code>document.cookie<\/code> property to create, retrieve, and delete cookies directly from the browser. Developers can also configure cookie attributes such as expiration dates, paths, domains, and security settings to control how cookies are stored and accessed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Understanding how JavaScript cookies work is important for developers who want to manage browser data effectively and improve website functionality.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this guide, you&#8217;ll learn how to <strong>set, get, and delete cookies using JavaScript<\/strong>, along with practical code examples, explanations, and important cookie security considerations.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What Are JavaScript Cookies?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Cookies are small key-value pairs that websites store in a user&#8217;s browser. They allow websites to remember information between HTTP requests because HTTP is a stateless protocol.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Whenever a browser sends a request to a website, matching cookies can automatically be included in the request headers.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">JavaScript cookies are commonly used for:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>User sessions:<\/strong> Maintaining session-related information.<\/li>\n\n\n\n<li><strong>User preferences:<\/strong> Remembering language, theme, and display settings.<\/li>\n\n\n\n<li><strong>Login functionality:<\/strong> Supporting authentication workflows when appropriately configured.<\/li>\n\n\n\n<li><strong>Shopping carts:<\/strong> Remembering cart-related information.<\/li>\n\n\n\n<li><strong>Website functionality:<\/strong> Maintaining useful information between page visits.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">A cookie consists of a name and value, along with optional attributes that control its expiration, availability, and security.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">document.cookie = \"username=Sujith; path=\/\";<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In this example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>username<\/code> is the cookie name.<\/li>\n\n\n\n<li><code>Sujith<\/code> is the cookie value.<\/li>\n\n\n\n<li><code>path=\/<\/code> makes the cookie available throughout the website.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Setting Cookies with JavaScript<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can create a cookie in JavaScript by assigning a string to the <code>document.cookie<\/code> property.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A cookie can include additional attributes such as <code>expires<\/code>, <code>max-age<\/code>, <code>path<\/code>, and <code>domain<\/code> to control its lifetime and availability.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example: Set a Cookie Using JavaScript<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The following function creates a cookie named <code>username<\/code> and sets its expiration date to seven days.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/04\/image-25.png\"><img fetchpriority=\"high\" decoding=\"async\" width=\"618\" height=\"337\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/04\/image-25.png\" alt=\"JavaScript set cookie example demonstrating how to create a username cookie with a seven-day expiration using document.cookie.\n\" class=\"wp-image-12813\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/04\/image-25.png 618w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/04\/image-25-300x164.png 300w\" sizes=\"(max-width: 618px) 100vw, 618px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Explanation<\/h3>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><code>new Date()<\/code> creates a new JavaScript date object.<\/li>\n\n\n\n<li><code>setTime()<\/code> calculates the expiration time by adding seven days.<\/li>\n\n\n\n<li><code>toUTCString()<\/code> converts the expiration date into the required UTC string format.<\/li>\n\n\n\n<li><code>document.cookie<\/code> creates the cookie with its name, value, expiration date, and path.<\/li>\n\n\n\n<li><code>alert()<\/code> displays a confirmation message.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">The cookie remains available until its expiration date unless it is deleted earlier.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Setting a Cookie Using max-age<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can also use the <code>max-age<\/code> attribute to specify how long a cookie should remain valid in seconds.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">document.cookie = \"username=Sujith; max-age=604800; path=\/\";<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here, <code>604800<\/code> represents seven days in seconds.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using <code>max-age<\/code> is a convenient alternative when you want to specify a cookie&#8217;s lifetime without calculating an expiration date.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Getting Cookies with JavaScript<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can retrieve cookies using the <code>document.cookie<\/code> property. It returns all cookies accessible to the current document as a semicolon-separated string.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When a website contains multiple cookies, you can split the returned string and search for a specific cookie by its name.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example: Get a Cookie Using JavaScript<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/04\/image-26.png\"><img decoding=\"async\" width=\"365\" height=\"189\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/04\/image-26.png\" alt=\"JavaScript get cookie example showing how to retrieve a specific username cookie using document.cookie and display its value in the browser.\" class=\"wp-image-12814\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/04\/image-26.png 365w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/04\/image-26-300x155.png 300w\" sizes=\"(max-width: 365px) 100vw, 365px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/04\/image-27.png\"><img decoding=\"async\" width=\"634\" height=\"185\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/04\/image-27.png\" alt=\"JavaScript get cookie example showing how to retrieve a specific username cookie using document.cookie and display its value in the browser.\" class=\"wp-image-12815\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/04\/image-27.png 634w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/04\/image-27-300x88.png 300w\" sizes=\"(max-width: 634px) 100vw, 634px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Explanation<\/h3>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><code>name + \"=\"<\/code> creates the cookie name pattern to search for.<\/li>\n\n\n\n<li><code>document.cookie.split(\";\")<\/code> separates all accessible cookies.<\/li>\n\n\n\n<li>The <code>for<\/code> loop checks each cookie individually.<\/li>\n\n\n\n<li><code>trim()<\/code> removes unnecessary spaces.<\/li>\n\n\n\n<li><code>startsWith()<\/code> checks whether the cookie matches the requested name.<\/li>\n\n\n\n<li><code>substring()<\/code> extracts and returns the cookie value.<\/li>\n\n\n\n<li>If the cookie does not exist, the function returns <code>null<\/code>.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">For example, if the <code>username<\/code> cookie contains <code>Sujith<\/code>, the browser console displays:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Sujith<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This method allows you to retrieve individual cookie values without manually checking the entire cookie string.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Deleting Cookies with JavaScript<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can delete a cookie in JavaScript by setting its expiration date to a time in the past or setting its <code>max-age<\/code> attribute to zero.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When deleting a cookie, make sure to use the same path and domain attributes that were used when creating it. Otherwise, the browser may not delete the intended cookie.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example: Delete a Cookie Using JavaScript<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/04\/image-28.png\"><img loading=\"lazy\" decoding=\"async\" width=\"599\" height=\"81\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/04\/image-28.png\" alt=\"JavaScript delete cookie example demonstrating how to remove a username cookie by setting its expiration date to a past date using document.cookie.\" class=\"wp-image-12816\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/04\/image-28.png 599w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/04\/image-28-300x41.png 300w\" sizes=\"(max-width: 599px) 100vw, 599px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/04\/image-29.png\"><img loading=\"lazy\" decoding=\"async\" width=\"632\" height=\"208\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/04\/image-29.png\" alt=\"JavaScript delete cookie example demonstrating how to remove a username cookie by setting its expiration date to a past date using document.cookie.\" class=\"wp-image-12817\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/04\/image-29.png 632w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/04\/image-29-300x99.png 300w\" sizes=\"(max-width: 632px) 100vw, 632px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Explanation<\/h3>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><code>username=<\/code> assigns an empty value to the cookie.<\/li>\n\n\n\n<li><code>max-age=0<\/code> instructs the browser to delete the cookie immediately.<\/li>\n\n\n\n<li><code>path=\/<\/code> specifies the cookie path used when creating it.<\/li>\n\n\n\n<li><code>alert()<\/code> displays a confirmation message.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">You can also delete a cookie using an expiration date in the past.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">document.cookie = \"username=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=\/\";<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Both approaches can be used to remove cookies, provided the original path and domain settings match.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Full Example: Set, Get, and Delete Cookies Using JavaScript<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The following complete example combines all three operations into one JavaScript implementation. You can use it to create a cookie, retrieve its value, and delete it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">JavaScript Code<\/h3>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/04\/image-30.png\"><img loading=\"lazy\" decoding=\"async\" width=\"550\" height=\"542\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/04\/image-30.png\" alt=\"Complete JavaScript cookies code example showing how to set, retrieve, and delete a username cookie using document.cookie, with browser developer tools displaying cookie informatio\n\" class=\"wp-image-12818\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/04\/image-30.png 550w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/04\/image-30-300x296.png 300w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">How to Use the Example<\/h3>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Call <code>setCookies()<\/code> to create a cookie named <code>username<\/code>.<\/li>\n\n\n\n<li>Call <code>getCookie(\"username\")<\/code> to retrieve the stored username.<\/li>\n\n\n\n<li>Check the returned value in the browser console.<\/li>\n\n\n\n<li>Call <code>deleteCookies()<\/code> to remove the cookie.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">You can test these functions in your browser&#8217;s developer console.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Important JavaScript Cookie Attributes<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">JavaScript cookies support several attributes that control their storage, accessibility, lifetime, and security.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><th>Attribute<\/th><th>Description<\/th><\/tr><tr><td><code>expires<\/code><\/td><td>Specifies the date and time when the cookie expires.<\/td><\/tr><tr><td><code>max-age<\/code><\/td><td>Defines the cookie lifetime in seconds.<\/td><\/tr><tr><td><code>path<\/code><\/td><td>Specifies the URL path where the cookie is available.<\/td><\/tr><tr><td><code>domain<\/code><\/td><td>Defines the domain that can access the cookie.<\/td><\/tr><tr><td><code>secure<\/code><\/td><td>Sends the cookie only over HTTPS connections.<\/td><\/tr><tr><td><code>samesite<\/code><\/td><td>Controls whether cookies are sent with cross-site requests.<\/td><\/tr><tr><td><code>httponly<\/code><\/td><td>Prevents JavaScript from accessing the cookie. It must be configured by the server.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Cookie Security Best Practices<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">When working with JavaScript cookies, security should always be considered.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use the <code>Secure<\/code> attribute to restrict cookies to HTTPS connections.<\/li>\n\n\n\n<li>Configure <code>SameSite<\/code> appropriately to help protect against cross-site request forgery (CSRF).<\/li>\n\n\n\n<li>Use <code>HttpOnly<\/code> for authentication cookies to prevent JavaScript access.<\/li>\n\n\n\n<li>Avoid storing passwords, authentication secrets, or sensitive personal information in JavaScript-accessible cookies.<\/li>\n\n\n\n<li>Set appropriate expiration dates to avoid keeping cookies longer than necessary.<\/li>\n\n\n\n<li>Use appropriate cookie consent mechanisms when required by applicable privacy regulations.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Important:<\/strong> Cookies created using JavaScript cannot be assigned the <code>HttpOnly<\/code> attribute. This attribute must be configured through an HTTP response from the server.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently Asked Questions (FAQs)<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. How do you set a cookie in JavaScript?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can set a cookie using the <code>document.cookie<\/code> property. Specify the cookie name, value, and optional attributes such as expiration date and path.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">document.cookie = \"username=Sujith; max-age=604800; path=\/\";<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This creates a cookie that remains valid for seven days.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. How can you get a specific cookie value using JavaScript?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can retrieve a specific cookie by accessing <code>document.cookie<\/code>, splitting the returned string, and searching for the required cookie name.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">function getCookie(name) {\n    const cookies = document.cookie.split(\";\");\n\n    for (let cookie of cookies) {\n        cookie = cookie.trim();\n\n        if (cookie.startsWith(name + \"=\")) {\n            return cookie.substring(name.length + 1);\n        }\n    }\n\n    return null;\n}\n\nconsole.log(getCookie(\"username\"));<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The function returns the cookie value if it exists; otherwise, it returns <code>null<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. How do you delete a cookie using JavaScript?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can delete a cookie by setting its <code>max-age<\/code> attribute to zero or assigning an expiration date in the past.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">document.cookie = \"username=; max-age=0; path=\/\";<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Ensure that the path and domain attributes match the original cookie settings so the correct cookie is removed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">JavaScript cookies provide a simple and effective way to store and manage small amounts of information in a user&#8217;s browser. By using the <code>document.cookie<\/code> property, developers can create cookies with expiration dates, retrieve stored values, and delete cookies when they are no longer needed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Understanding how to set, get, and delete cookies helps developers manage user preferences, maintain website sessions, and improve the overall browsing experience.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Always configure cookies with appropriate security attributes and avoid storing sensitive information in cookies that can be accessed through JavaScript. Following these practices helps developers build more secure, reliable, and user-friendly web applications.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Need Help with JavaScript Development<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Looking for reliable JavaScript development, web application security, or software development solutions?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Pheonix Solutions<\/strong> provides technology services covering software development, application security, cloud infrastructure, DevOps, and technical support.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Our experts can help you build secure web applications, implement effective authentication mechanisms, and maintain reliable software systems.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Explore our <a href=\"https:\/\/pheonixsolutions.com\/software-development\/\">Software Development Services<\/a> to learn more.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Need assistance with your project? <a href=\"https:\/\/pheonixsolutions.com\/contact\">Contact our experts<\/a> to discuss your requirements.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Post Date: April 26, 2025Last Updated: November 03, 2026 Introduction JavaScript cookies are small pieces of data stored in a [&hellip;]<\/p>\n","protected":false},"author":514,"featured_media":12820,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[],"class_list":["post-8852","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-architecture","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-2iM","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2025\/04\/JavaScript-Cookies-Tutorial-Banner.png","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8852","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/514"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=8852"}],"version-history":[{"count":3,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8852\/revisions"}],"predecessor-version":[{"id":12843,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8852\/revisions\/12843"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media\/12820"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=8852"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=8852"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=8852"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}