This is a better version of detect_logged_in() for webcit-ng that
[citadel.git] / webcit-ng / static / js / util.js
index 201247450aa720bd6803710bcfb424ce42046597..2499ca759bc1f053da5b5f9b5a98759fdfd57400 100644 (file)
@@ -114,3 +114,12 @@ function convertTimestamp(timestamp) {
                
        return time;
 }
+
+
+// Get the value of a cookie from the HTTP session
+// Shamelessly swiped from https://stackoverflow.com/questions/5639346/what-is-the-shortest-function-for-reading-a-cookie-by-name-in-javascript
+const getCookieValue = (name) => (
+       document.cookie.match('(^|;)\\s*' + name + '\\s*=\\s*([^;]+)')?.pop() || ''
+)
+
+