{"result":{"depiction_url":null,"edges":{"subject":{"objects":[{"created":"2026-09-30T09:11:24Z","object_id":{"id":2555,"is_a":["categorization","keyword","keyword_information_type"],"name":"zotonic_topic_reference","title":"Reference","uri":"https:\/\/zotonic.com\/id\/2555"},"seq":1},{"created":"2026-09-30T09:11:24Z","object_id":{"id":2563,"is_a":["categorization","keyword","keyword_audience"],"name":"zotonic_topic_frontend_developer","title":"Frontend developer","uri":"https:\/\/zotonic.com\/id\/2563"},"seq":2},{"created":"2026-09-30T09:11:24Z","object_id":{"id":2625,"is_a":["categorization","keyword","keyword_architecture"],"name":"zotonic_topic_model","title":"Model","uri":"https:\/\/zotonic.com\/id\/2625"},"seq":3},{"created":"2026-09-30T09:11:24Z","object_id":{"id":2666,"is_a":["categorization","keyword","keyword_data_type"],"name":"zotonic_topic_identifier","title":"Identifier","uri":"https:\/\/zotonic.com\/id\/2666"},"seq":4},{"created":"2026-09-30T09:11:24Z","object_id":{"id":2673,"is_a":["categorization","keyword","keyword_technology"],"name":"zotonic_topic_javascript","title":"JavaScript","uri":"https:\/\/zotonic.com\/id\/2673"},"seq":5},{"created":"2026-09-30T09:11:24Z","object_id":{"id":2713,"is_a":["categorization","keyword","keyword_domain"],"name":"zotonic_topic_browser_storage","title":"Browser storage","uri":"https:\/\/zotonic.com\/id\/2713"},"seq":6},{"created":"2026-09-30T09:11:24Z","object_id":{"id":2718,"is_a":["categorization","keyword","keyword_technology"],"name":"zotonic_topic_cotonic","title":"Cotonic","uri":"https:\/\/zotonic.com\/id\/2718"},"seq":7}],"predicate":{"id":308,"is_a":["meta","predicate"],"name":"subject","title":{"_type":"trans","tr":{"en":"Keyword"}},"uri":"http:\/\/purl.org\/dc\/elements\/1.1\/subject"}}},"id":2743,"is_a":["text","documentation","reference","cotonic_reference","cotonic_model"],"links":[{"rel":"self","target":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/2743"},{"rel":"hub","target":"https:\/\/zotonic.com\/.zotonic\/websub"}],"medium":null,"medium_url":null,"name":"doc_cotonic_model_sessionid","page_url":{"en":"https:\/\/zotonic.com\/cotonic\/models\/sessionid","x-default":"https:\/\/zotonic.com\/cotonic\/models\/sessionid"},"preview_url":null,"resource":{"version":17,"pivot_location_lat":null,"title":"model\/sessionId","is_authoritative":true,"body":"<a name=\"model.sessionId\"><\/a><h3>model\/sessionId<\/h3>\n            <p>\n            The sessionId model manages a browser identifier stored as JSON under\n            <tt>cotonic-sid<\/tt> in localStorage. It is shared by pages on the same\n            origin and survives page reloads and browser restarts until it is reset,\n            deleted, or the browser storage is cleared. It is not limited to a tab\n            or to a sessionStorage session.\n            <\/p>\n            <p>\n            On initialization the model reuses a non-empty stored identifier or\n            generates a new one. It also writes a <tt>cotonic-sid<\/tt> cookie through\n            the <a href=\"\/id\/doc_cotonic_model_document#model.document\">document model<\/a>, using\n            <tt>SameSite=Strict<\/tt>. A newly generated identifier gets a four-day\n            cookie; reusing an identifier on initialization refreshes the cookie\n            for fourteen days. Cookie expiry does not remove the localStorage value.\n            <\/p>\n            <p>\n            The identifier has a UUID-like shape and is generated using\n            <tt>Math.random()<\/tt>. It is not an authentication token or a\n            cryptographically secure identifier.\n            <\/p>\n\n            <a name=\"model.sessionId.get\"><\/a><h4>get<\/h4><p>\n            Call <tt>model\/sessionId\/get<\/tt> to retrieve the stored identifier as\n            the response payload. If the localStorage value is missing or cannot\n            be parsed as JSON, a new identifier is generated. The request must have\n            a response topic; use <tt>cotonic.broker.call<\/tt> or a worker&#39;s\n            <tt>self.call<\/tt>.\n            <\/p>\n            <pre>\ncotonic.broker.call(&quot;model\/sessionId\/get&quot;).then(function(msg) {\n    console.log(&quot;Browser identifier:&quot;, msg.payload);\n});<\/pre>\n\n            <a name=\"model.sessionId.post.reset\"><\/a><h4>post\/reset<\/h4><p>\n            Generate and store a new identifier, update the cookie, and publish\n            the new identifier on <tt>model\/sessionId\/event<\/tt>. When called with\n            a response topic, return the new identifier as the response payload.\n            The request payload is not used.\n            <\/p>\n            <pre>\ncotonic.broker.call(&quot;model\/sessionId\/post\/reset&quot;).then(function(msg) {\n    console.log(&quot;New browser identifier:&quot;, msg.payload);\n});<\/pre>\n\n            <a name=\"model.sessionId.delete\"><\/a><h4>delete<\/h4><p>\n            Remove the localStorage value, expire the cookie, and publish\n            <tt>null<\/tt> on <tt>model\/sessionId\/event<\/tt>. If the request has a\n            response topic, its response payload is also <tt>null<\/tt>. A later\n            <tt>get<\/tt> call or model initialization generates a new identifier.\n            <\/p>\n            <pre>\ncotonic.broker.publish(&quot;model\/sessionId\/delete&quot;);<\/pre>\n\n            <a name=\"model.sessionId.event\"><\/a><h4>event<\/h4><p>\n            Identifier generation and reset publish the new string; deletion\n            publishes <tt>null<\/tt>. These messages are not retained. Reusing an\n            existing identifier on initialization does not publish this event;\n            call <tt>get<\/tt> to read the current value.\n            <\/p>\n            <p>\n            Changes from other tabs are forwarded from\n            <tt>model\/localStorage\/event\/cotonic-sid<\/tt>. The current implementation\n            forwards the complete storage message as the event payload, so the\n            identifier for these forwarded events is in <tt>msg.payload.payload<\/tt>.\n            <\/p>\n            <pre>\ncotonic.broker.subscribe(&quot;model\/sessionId\/event&quot;, function(msg) {\n    const value = msg.payload;\n    const id = value !== null &amp;&amp; typeof value === &quot;object&quot;\n        ? value.payload\n        : value;\n    console.log(&quot;Browser identifier changed:&quot;, id);\n});<\/pre>\n\n            <a name=\"model.sessionId.event.ping\"><\/a><h4>event\/ping<\/h4><p>\n            After initialization the model publishes the retained payload\n            <tt>&quot;pong&quot;<\/tt> on <tt>model\/sessionId\/event\/ping<\/tt>. Subscribe to this\n            topic to detect that the model is available.\n            <\/p>\n            <pre>\ncotonic.broker.subscribe(&quot;model\/sessionId\/event\/ping&quot;, function(msg) {\n    console.log(&quot;sessionId model is available:&quot;, msg.payload);\n});<\/pre>\n\n            ","slug":"model-sessionid","is_protected":false,"visible_for":0,"tz":"UTC","language":["en"],"doc_source_hash":"970a83ce3699d95fffc7c4e705952fb52af230d5c3d628cc3ead9c8de12fc334","is_featured":false,"content_group_id":{"id":2551,"is_a":["meta","content_group"],"name":"content_group_imported_docs","title":"Imported documentation","uri":"https:\/\/zotonic.com\/id\/content_group_imported_docs"},"category_id":{"id":2723,"is_a":["meta","category"],"name":"cotonic_model","title":"Cotonic models","uri":"https:\/\/zotonic.com\/id\/cotonic_model"},"doc_source_path":"index.html","publication_start":"2026-09-30T09:11:24Z","page_path":"\/cotonic\/models\/sessionid","github_url":"https:\/\/github.com\/cotonic\/cotonic\/blob\/master\/index.html","pivot_location_lng":null,"doc_source_kind":"cotonic","name":"doc_cotonic_model_sessionid","is_unfindable":false,"is_published":true,"pivot_geocode":null,"created":"2026-09-30T09:11:24Z","uri":null,"doc_source_anchor":"model.sessionId","doc_status":"current","is_dependent":false,"publication_end":"9999-06-01T00:00:00Z","modifier_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"privacy":0,"doc_source_commit":"f88cc928b997d10f7f19e6bd0ede80e1c8c619bc","creator_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"modified":"2026-09-30T09:57:32Z","title_slug":"model-sessionid"},"uri":"https:\/\/zotonic.com\/id\/2743","uri_template":"https:\/\/zotonic.com\/id\/:id","websub":{"hub":"https:\/\/zotonic.com\/.zotonic\/websub","topic":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/2743"}},"status":"ok"}