XF 2.1 xf_toggle being deleted

Grahame

Member
Can anyone help me figure out why the xf_toggle cookie is being deleted on browser-close? The user isn't logging out, and I even went as far as to add "toggle" to clearCookieSkipList in Login.php just to be safe. It's only happening to some of our users not all and it doesn't seem to be browser or platform specific - is there a way to change xf_toggle from a session cookie to a dated one the same as tfa_trust and user? Or is there something else causing the browser to not keep this cookie on close?
 
By default xf_toggle is stored in the browser's local storage, not in a cookie. Some users may have their browser (or a browser extension) configured to clear local storage when closed.
 
By default xf_toggle is stored in the browser's local storage, not in a cookie. Some users may have their browser (or a browser extension) configured to clear local storage when closed.
Thanks, that's kind of where I was leaning (that it was a browser option) - do you know of a way to change xf_toggle to use a 'real' cookie? xf_toggle does show up in the cookie section of Chrome dev tools which is why I thought it was a cookie not just local browser storage.
 
Hmm, if it shows up in the cookie section then it might already be stored as a cookie. Is this toggler something in the core, or from an add-on or custom theme? It looks like there's support in the toggle storage data API for setting an expiry value, but no way to pass it down from the toggle handlers themselves.
 
Hmm, if it shows up in the cookie section then it might already be stored as a cookie. Is this toggler something in the core, or from an add-on or custom theme? It looks like there's support in the toggle storage data API for setting an expiry value, but no way to pass it down from the toggle handlers themselves.
data-xf-click="toggle" data-xf-init="toggle-storage" data-storage-type="cookie" data-target=".block--category{$node.node_id} .block-body" data-storage-key="_node-{$node.node_id}">

thats the code that’s setting the toggle, it’s for collapsing the nodes in specific sections
 
Ah okay. Yeah, then it is being stored as a regular cookie which defaults to session expiry. There's no way to set an expiration date in the toggle handler without extending it in an add-on. Generally, local storage should persist for longer than the session so it might actually be better to use that instead (by removing data-storage-type).
 
Ah okay. Yeah, then it is being stored as a regular cookie which defaults to session expiry. There's no way to set an expiration date in the toggle handler without extending it in an add-on. Generally, local storage should persist for longer than the session so it might actually be better to use that instead (by removing data-storage-type).
Thanks, giving that a try - I can't replicate the problem with cookies so need to wait for a user to report back :)
 
data-xf-click="toggle" data-xf-init="toggle-storage" data-storage-type="cookie" data-target=".block--category{$node.node_id} .block-body" data-storage-key="_node-{$node.node_id}">

thats the code that’s setting the toggle, it’s for collapsing the nodes in specific sections

Where do I find this? My users are upset they collapse nodes they are not interested in and then later on they are all open again. I wish this was stored in the database.
 
Where do I find this? My users are upset they collapse nodes they are not interested in and then later on they are all open again. I wish this was stored in the database.
In mine it's in the node_list_category template, just remove data_storage_type="cookie" from the line.

edit : I think you're using the XD Collapsible Sections add-on in which case you need to edit the /src/addons/XDinc/Collapsible/template_modifications.xml to find the line with data-storage-type in it.

Then rebuild the plugin (ignore the warning about the file not being as expected)
 
Last edited:
Back
Top Bottom