{"_id":"53fe8159addab8973c1af2c1","parentDoc":null,"comments":[],"tags":[],"version":{"_id":"53fe6dc5addab8973c1af26a","__v":19,"project":"53fe6dc5addab8973c1af267","createdAt":"2014-08-27T23:46:13.941Z","releaseDate":"2014-08-27T23:46:13.941Z","categories":["53fe6dc5addab8973c1af26b","53fe71a2addab8973c1af276","53fe7d89addab8973c1af2b0","53fe7d8daddab8973c1af2b1","53fe836faddab8973c1af2ce","53ff9a4823a37e1d5cebafe1","53ff9e3723a37e1d5cebaff7","53ffaca523a37e1d5cebb039","53ffad2e23a37e1d5cebb03c","5400c7d2ec93b29b61d4f7be","5400f0e1ec93b29b61d4f7dd","54d5636323010a0d001aca81","54d565c1276f8e0d00feab54","54ff40532882a10d00546927","556606d25561af0d008208b7","558c91900b236c2500d37c9a","56180a14f8c9632100ac7599","564fb3a59b4fab1700187518","5702e2d2f2d6f336005e901f"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"__v":4,"category":{"_id":"53fe7d89addab8973c1af2b0","__v":6,"version":"53fe6dc5addab8973c1af26a","pages":["53fe7e17addab8973c1af2bb","53fe80ebaddab8973c1af2be","54011f0ec1c1764f69827203","53fe8159addab8973c1af2c1","53fe81ecaddab8973c1af2c5","54d94b3c6a09052100a6b699","56d49a9da4a9211b00c8f118"],"project":"53fe6dc5addab8973c1af267","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-08-28T00:53:29.717Z","from_sync":false,"order":6,"slug":"logout-reference","title":"Logout Reference"},"user":"53fe6d8baddab8973c1af266","project":"53fe6dc5addab8973c1af267","is_link":false,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2014-08-28T01:09:45.710Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","try":true,"auth":"never","params":[],"url":""},"isReference":false,"order":3,"body":"Now that we have the clef_id of the user that is logging out, we can log them out through the database. To do this, we must add a field in our database, which holds a logged out timestamp for each user. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \" > ALTER TABLE user\\n-> ADD COLUMN logged_out_at\\n-> DATETIME;\\n                 \",\n      \"language\": \"mysql\"\n    }\n  ]\n}\n[/block]\nWith that field added and the users clef_id in hand from the logout webhook, we can set their logged_out_at timestamp.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \" > UPDATE TABLE user\\n-> SET logged_out_at=(now())\\n-> WHERE id=clef_id;\\n                        \",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\n# Next up\nNow that you've updated the `logged_out_at` field on the user, you'll need to ensure that you [check to make sure the user is logged in](/v1.0/docs/checking-timestamped-logins) every request.\n[block:html]\n{\n  \"html\": \"<div></div>\\n<a class=\\\"clef-button blue\\\" href=\\\"/v1.0/docs/checking-timestamped-logins\\\">Go to the next section</a>\\n<style></style>\"\n}\n[/block]","excerpt":"","slug":"database-logout","type":"basic","title":"Database logout"}
Now that we have the clef_id of the user that is logging out, we can log them out through the database. To do this, we must add a field in our database, which holds a logged out timestamp for each user. [block:code] { "codes": [ { "code": " > ALTER TABLE user\n-> ADD COLUMN logged_out_at\n-> DATETIME;\n ", "language": "mysql" } ] } [/block] With that field added and the users clef_id in hand from the logout webhook, we can set their logged_out_at timestamp. [block:code] { "codes": [ { "code": " > UPDATE TABLE user\n-> SET logged_out_at=(now())\n-> WHERE id=clef_id;\n ", "language": "text" } ] } [/block] # Next up Now that you've updated the `logged_out_at` field on the user, you'll need to ensure that you [check to make sure the user is logged in](/v1.0/docs/checking-timestamped-logins) every request. [block:html] { "html": "<div></div>\n<a class=\"clef-button blue\" href=\"/v1.0/docs/checking-timestamped-logins\">Go to the next section</a>\n<style></style>" } [/block]