Skip to content

Commit 0f51ca5

Browse files
authored
Merge pull request #18158 from craftcms/chore/cookie-name-tweak
Use periods instead of colons in cookie names
2 parents e7d0b38 + 0bfe265 commit 0f51ca5

File tree

7 files changed

+9
-8
lines changed

7 files changed

+9
-8
lines changed

CHANGELOG-WIP.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@
139139
- Improved element index performance. ([#17557](https://github.com/craftcms/cms/pull/17557))
140140
- Improved element query performance. ([#17850](https://github.com/craftcms/cms/pull/17850))
141141
- Reduced the number of queries executed when working with nested entries, addresses, and content blocks. ([#18142](https://github.com/craftcms/cms/issues/18142))
142+
- Session-based cookies no longer use colons (`:`) in their names. ([#18158](https://github.com/craftcms/cms/pull/18158))
142143
- Fixed a bug where elements with unsaved changes could show outdated attribute/field values within element index tables, chips, and cards throughout the control panel. ([#17915](https://github.com/craftcms/cms/pull/17915))
143144
- Fixed a bug where Table fields with the “Static Rows” setting enabled would lose track of which values belonged to which row headings, if the “Default Values” table was reordered. ([#17090](https://github.com/craftcms/cms/issues/17090))
144145
- Fixed a bug where requests with invalid tokens would throw an exception before the application was fully initialized, which could lead to other errors. ([#18000](https://github.com/craftcms/cms/issues/18000))

src/templates/_elements/sources.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
{% if source.heading | length %}
8989
{% embed '_includes/disclosure-toggle' with {
9090
persist: true,
91-
storageKey: 'sources-list:' ~ key,
91+
storageKey: 'sources-list.' ~ key,
9292
controls: sourceId,
9393
attributes: {
9494
class: 'source-item__toggle'
@@ -120,7 +120,7 @@
120120
{% if source.nested is defined and source.nested is not empty %}
121121
{% embed '_includes/disclosure-toggle' with {
122122
persist: true,
123-
storageKey: 'sources-list:'~ key,
123+
storageKey: 'sources-list.'~ key,
124124
controls: key,
125125
attributes: {
126126
class: 'source-item__toggle'

src/templates/_includes/disclosure-toggle.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
{% set cookieState = null %}
1111
{% if persist and storageMode == 'cookies' and storageKey %}
12-
{% set cookieState = storageKey ? craft.app.request.rawCookies.value('Craft-' ~ craft.app.systemUid ~ ':' ~ storageKey) : null %}
12+
{% set cookieState = storageKey ? craft.app.request.rawCookies.value("Craft-#{craft.app.systemUid}.#{storageKey}") : null %}
1313
{% endif %}
1414

1515
{% set state = state ?? cookieState %}

src/templates/_layouts/cp.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ history.replaceState(undefined, undefined, window.location.href.match(/^[^#]*/)[
327327
</div><!-- #content-container -->
328328

329329
{% if details is not empty %}
330-
<div id="details-container" tabindex="-1" data-state="{{ craft.app.request.rawCookies.value('Craft-' ~ craft.app.systemUid ~ ':sidebar-details')}}">
330+
<div id="details-container" tabindex="-1" data-state="{{ craft.app.request.rawCookies.value("Craft-#{craft.app.systemUid}.sidebar-details")}}">
331331
<div id="details">
332332
<div class="details">
333333
{{ details|raw }}

src/web/assets/cp/dist/cp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/web/assets/cp/dist/cp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/web/assets/cp/src/js/Craft.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2388,7 +2388,7 @@ $.extend(Craft, {
23882388
// Adapted from https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie
23892389
return document.cookie.replace(
23902390
new RegExp(
2391-
`(?:(?:^|.*;\\s*)Craft-${Craft.systemUid}:${name}\\s*\\=\\s*([^;]*).*$)|^.*$`
2391+
`(?:(?:^|.*;\\s*)Craft-${Craft.systemUid}.${name}\\s*\\=\\s*([^;]*).*$)|^.*$`
23922392
),
23932393
'$1'
23942394
);
@@ -2410,7 +2410,7 @@ $.extend(Craft, {
24102410
*/
24112411
setCookie: function (name, value, options) {
24122412
options = $.extend({}, this.defaultCookieOptions, options);
2413-
let cookie = `Craft-${Craft.systemUid}:${name}=${encodeURIComponent(
2413+
let cookie = `Craft-${Craft.systemUid}.${name}=${encodeURIComponent(
24142414
value
24152415
)}`;
24162416
if (options.path) {

0 commit comments

Comments
 (0)