{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","settings":"","results":{"codes":[]},"params":[]},"next":{"description":"","pages":[]},"title":"Clear Session Identity","type":"fn","slug":"clear-session","excerpt":"Clears this browser's identity and starts a new anonymous browsing session","body":"When a user has changed from one identity to another, the `clear` function should be called to start a new browsing history. This should always be called when a user logs out of an identified session.\n\nWhen called, `p13n.js` will stop tracking this user as the previously-identified user, clear all browser cookies previously stored, and start a new anonymous browsing profile for subsequent behavior for this browser.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"bt('clear', settings={});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nThe `clear` function has one field:\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"`settings`\",\n    \"0-2\": \"Settings specific to this event. Currently supports specification of `onComplete`, `onSuccess`, and `onFailure` callback functions. See Settings below for more information.\",\n    \"0-1\": \"Object\",\n    \"h-0\": \"Field\",\n    \"h-2\": \"Description\",\n    \"h-1\": \"Type\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"Settings\"\n}\n[/block]\nThe `settings` object is used for configuring the `clear` call.\n\nThree `settings` objects are currently allowed for `clear` calls using the `p13n.js` library: \n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Object\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"`onComplete`\",\n    \"1-0\": \"`onFailure(error)`\",\n    \"2-0\": \"`onSuccess`\",\n    \"0-1\": \"This setting allows the caller to specify a callback function once the clear function has completed. The function will be called regardless of whether the clear was successful or not. The function should have no parameters (nothing will be passed to it).\",\n    \"1-1\": \"This setting allows the caller to specify a callback function if the clear function has completed with an error. The error raised by the `clear` function will be passed into this callback.\",\n    \"2-1\": \"This setting allows the caller to specify a callback function once the clear function has completed successfully. The function should have no parameters (nothing will be passed to it).\"\n  },\n  \"cols\": 2,\n  \"rows\": 3\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"bt('clear', {onComplete: function() { console.log('Clear function completed!'); }});\",\n      \"language\": \"json\",\n      \"name\": \"onComplete Example\"\n    },\n    {\n      \"code\": \"bt('clear', {onFailure: function(err) { console.log('Error!: ' + err); }});\",\n      \"language\": \"javascript\",\n      \"name\": \"onFailure Example\"\n    },\n    {\n      \"code\": \"bt('clear', {onSuccess: function() { console.log('All clear!'); }});\",\n      \"language\": \"javascript\",\n      \"name\": \"onSuccess Example\"\n    }\n  ]\n}\n[/block]","updates":[],"order":2,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"5a9ded277d3064001286ec56","project":"56aff08c3a5b810d00745d99","version":{"version":"1","version_clean":"1.0.0","codename":"","is_stable":true,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["56aff08d3a5b810d00745d9d","56aff24f3a5b810d00745da0","56aff25dbc304a0d00ace207","56aff287e0b1e40d00c53798","56aff2b260a37a0d00ed8883","56aff2b8e0b1e40d00c53799","56aff2bd5b1f01170014dc7b","56aff2c9d21e9c0d00b62993","56aff493aef9a21700da0e67","56aff4ce1486990d009c0f64","56aff4da5b1f01170014dc7d","56aff4dfe0b1e40d00c537a2","56aff4e59d32e30d0006d3e9","56aff4e91486990d009c0f65","56aff4f93a5b810d00745da2","56aff4fe9d32e30d0006d3ea","56b91c7ab1e03e0d001057c5","56c4f51aba4a540d0091b9a2","56cd09488c4a331d002c1e44","56d4ec4773dcd20b00fb8769","56e79bc515f96b2200878e54","56ec25c538ff1d2200d56cc2","56ec3a6f36bc8e0e00f190c8","56ec3e308ea7ce0e00a3d8b0","5724d8fe4255580e005938b2","5724dc842ad0bc1700122803","5776ef2a04f7500e0095dc37","57ab9f70b5e8742000e17eb9","57d7117646dcc30e007dd21f","58e6abd5b1eece19008b7d31","59288c65e2653627003e1221","5a8f4797a44f8600128e75ee","5bbf8833eb416300039a2c14","5ea811617bf4b5007328a0af"],"_id":"56aff08c3a5b810d00745d9c","project":"56aff08c3a5b810d00745d99","releaseDate":"2016-02-01T23:55:56.544Z","__v":34,"createdAt":"2016-02-01T23:55:56.544Z"},"category":{"sync":{"isSync":false,"url":""},"pages":[],"title":"Zeta JavaScript Library","slug":"zetahub-javascript-library","order":1,"from_sync":false,"reference":false,"_id":"5a8f4797a44f8600128e75ee","project":"56aff08c3a5b810d00745d99","version":"56aff08c3a5b810d00745d9c","createdAt":"2018-02-22T22:43:35.027Z","__v":0},"user":"566887ff8639090d00759415","createdAt":"2018-03-06T01:21:43.939Z","githubsync":"","__v":0,"parentDoc":null}

Clear Session Identity

Clears this browser's identity and starts a new anonymous browsing session

When a user has changed from one identity to another, the `clear` function should be called to start a new browsing history. This should always be called when a user logs out of an identified session. When called, `p13n.js` will stop tracking this user as the previously-identified user, clear all browser cookies previously stored, and start a new anonymous browsing profile for subsequent behavior for this browser. [block:code] { "codes": [ { "code": "bt('clear', settings={});", "language": "javascript" } ] } [/block] The `clear` function has one field: [block:parameters] { "data": { "0-0": "`settings`", "0-2": "Settings specific to this event. Currently supports specification of `onComplete`, `onSuccess`, and `onFailure` callback functions. See Settings below for more information.", "0-1": "Object", "h-0": "Field", "h-2": "Description", "h-1": "Type" }, "cols": 3, "rows": 1 } [/block] [block:api-header] { "title": "Settings" } [/block] The `settings` object is used for configuring the `clear` call. Three `settings` objects are currently allowed for `clear` calls using the `p13n.js` library: [block:parameters] { "data": { "h-0": "Object", "h-1": "Description", "0-0": "`onComplete`", "1-0": "`onFailure(error)`", "2-0": "`onSuccess`", "0-1": "This setting allows the caller to specify a callback function once the clear function has completed. The function will be called regardless of whether the clear was successful or not. The function should have no parameters (nothing will be passed to it).", "1-1": "This setting allows the caller to specify a callback function if the clear function has completed with an error. The error raised by the `clear` function will be passed into this callback.", "2-1": "This setting allows the caller to specify a callback function once the clear function has completed successfully. The function should have no parameters (nothing will be passed to it)." }, "cols": 2, "rows": 3 } [/block] [block:code] { "codes": [ { "code": "bt('clear', {onComplete: function() { console.log('Clear function completed!'); }});", "language": "json", "name": "onComplete Example" }, { "code": "bt('clear', {onFailure: function(err) { console.log('Error!: ' + err); }});", "language": "javascript", "name": "onFailure Example" }, { "code": "bt('clear', {onSuccess: function() { console.log('All clear!'); }});", "language": "javascript", "name": "onSuccess Example" } ] } [/block]