Przeglądaj źródła

Drupal 8 session cookie access.

Frederic G. MARAND 9 lat temu
rodzic
commit
43f8e7f0c3

+ 1 - 0
client/templates/includes/header.html

@@ -17,6 +17,7 @@
           {{/if}}
       </ul>
       <ul class="nav navbar-nav navbar-right">
+        <li><a href="http://drop8/">Session: {{ drupalSessionCookie }}</a></li>
         {{> loginButtons}}
       </ul>
     </div>

+ 24 - 0
client/templates/includes/header.js

@@ -0,0 +1,24 @@
+/**
+ * @file
+ *
+ *
+ * User: marand
+ * Date: 05/09/15
+ * Time: 12:52
+ */
+
+Template.header.helpers({
+  drupalSessionCookie: function () {
+    var cookies = document.cookie.split(';');
+    var result = '<not set>';
+
+    cookies.forEach(function (item) {
+      item = item.trim().split('=');
+      if (item[0] === 'SESS2767e46e15422527777376ba0aeecd4b') {
+        result = item[1];
+      }
+    });
+
+    return result;
+  }
+});