<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Macro (JScript/VB) to extract the Browser Cookies/SMSESSION cookie in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Macro-JScript-VB-to-extract-the-Browser-Cookies-SMSESSION-cookie/m-p/1345451#M460578</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a requirement to fetch the SMSESSION cookie from the browser, that will be used as one of the header in calling a WebService later.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Went thru multiple sites to understand the code and also below are the sample codes to extract in browser console. But somehow those are not working in Macro edit pane. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;STRONG style="color: blue; font-size: 9.0pt; font-family: 'Courier New';"&gt;function&lt;/STRONG&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt; readCookie(&lt;/SPAN&gt;&lt;STRONG style="color: blue; font-size: 9.0pt; font-family: 'Courier New';"&gt;name&lt;/STRONG&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt;){&lt;BR /&gt; &lt;/SPAN&gt;&lt;STRONG style="color: blue; font-size: 9.0pt; font-family: 'Courier New';"&gt;var&lt;/STRONG&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt; nameEQ = &lt;/SPAN&gt;&lt;STRONG style="color: blue; font-size: 9.0pt; font-family: 'Courier New';"&gt;name&lt;/STRONG&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt; + "=";&lt;BR /&gt; &lt;/SPAN&gt;&lt;STRONG style="color: blue; font-size: 9.0pt; font-family: 'Courier New';"&gt;var&lt;/STRONG&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt; theCookies = document.cookie.&lt;/SPAN&gt;&lt;STRONG style="color: blue; font-size: 9.0pt; font-family: 'Courier New';"&gt;split&lt;/STRONG&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt;(';');&lt;BR /&gt; &lt;/SPAN&gt;&lt;STRONG style="color: blue; font-size: 9.0pt; font-family: 'Courier New';"&gt;var&lt;/STRONG&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt; aString = '';&lt;BR /&gt; &lt;/SPAN&gt;&lt;STRONG style="color: blue; font-size: 9.0pt; font-family: 'Courier New';"&gt;for&lt;/STRONG&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt; (&lt;/SPAN&gt;&lt;STRONG style="color: blue; font-size: 9.0pt; font-family: 'Courier New';"&gt;var&lt;/STRONG&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt; i = 1 ; i &amp;lt;= theCookies.&lt;/SPAN&gt;&lt;STRONG style="color: blue; font-size: 9.0pt; font-family: 'Courier New';"&gt;length&lt;/STRONG&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt;; i++) {&lt;BR /&gt; aString += i + ' ' + theCookies[i-1] + "\n";&lt;BR /&gt; }&lt;BR /&gt; &lt;/SPAN&gt;&lt;STRONG style="color: blue; font-size: 9.0pt; font-family: 'Courier New';"&gt;return&lt;/STRONG&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt; aString;&lt;BR /&gt; } &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;CODE style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;"&gt;&lt;SPAN class="kwd" style="color: #101094;"&gt;var&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; x &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; document&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;cookie&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;;&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; &lt;BR /&gt;window&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;alert&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;x&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;);&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If somehow that cookie value can be captured in variable or exported to notepad - that would be a help. Could someone please suggest?&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 01 May 2017 19:10:01 GMT</pubDate>
    <dc:creator>dmohanty</dc:creator>
    <dc:date>2017-05-01T19:10:01Z</dc:date>
    <item>
      <title>Macro (JScript/VB) to extract the Browser Cookies/SMSESSION cookie</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-JScript-VB-to-extract-the-Browser-Cookies-SMSESSION-cookie/m-p/1345451#M460578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a requirement to fetch the SMSESSION cookie from the browser, that will be used as one of the header in calling a WebService later.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Went thru multiple sites to understand the code and also below are the sample codes to extract in browser console. But somehow those are not working in Macro edit pane. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;STRONG style="color: blue; font-size: 9.0pt; font-family: 'Courier New';"&gt;function&lt;/STRONG&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt; readCookie(&lt;/SPAN&gt;&lt;STRONG style="color: blue; font-size: 9.0pt; font-family: 'Courier New';"&gt;name&lt;/STRONG&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt;){&lt;BR /&gt; &lt;/SPAN&gt;&lt;STRONG style="color: blue; font-size: 9.0pt; font-family: 'Courier New';"&gt;var&lt;/STRONG&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt; nameEQ = &lt;/SPAN&gt;&lt;STRONG style="color: blue; font-size: 9.0pt; font-family: 'Courier New';"&gt;name&lt;/STRONG&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt; + "=";&lt;BR /&gt; &lt;/SPAN&gt;&lt;STRONG style="color: blue; font-size: 9.0pt; font-family: 'Courier New';"&gt;var&lt;/STRONG&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt; theCookies = document.cookie.&lt;/SPAN&gt;&lt;STRONG style="color: blue; font-size: 9.0pt; font-family: 'Courier New';"&gt;split&lt;/STRONG&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt;(';');&lt;BR /&gt; &lt;/SPAN&gt;&lt;STRONG style="color: blue; font-size: 9.0pt; font-family: 'Courier New';"&gt;var&lt;/STRONG&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt; aString = '';&lt;BR /&gt; &lt;/SPAN&gt;&lt;STRONG style="color: blue; font-size: 9.0pt; font-family: 'Courier New';"&gt;for&lt;/STRONG&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt; (&lt;/SPAN&gt;&lt;STRONG style="color: blue; font-size: 9.0pt; font-family: 'Courier New';"&gt;var&lt;/STRONG&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt; i = 1 ; i &amp;lt;= theCookies.&lt;/SPAN&gt;&lt;STRONG style="color: blue; font-size: 9.0pt; font-family: 'Courier New';"&gt;length&lt;/STRONG&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt;; i++) {&lt;BR /&gt; aString += i + ' ' + theCookies[i-1] + "\n";&lt;BR /&gt; }&lt;BR /&gt; &lt;/SPAN&gt;&lt;STRONG style="color: blue; font-size: 9.0pt; font-family: 'Courier New';"&gt;return&lt;/STRONG&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt; aString;&lt;BR /&gt; } &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;CODE style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;"&gt;&lt;SPAN class="kwd" style="color: #101094;"&gt;var&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; x &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; document&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;cookie&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;;&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt; &lt;BR /&gt;window&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;alert&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: #303336;"&gt;x&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: #303336;"&gt;);&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If somehow that cookie value can be captured in variable or exported to notepad - that would be a help. Could someone please suggest?&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 May 2017 19:10:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-JScript-VB-to-extract-the-Browser-Cookies-SMSESSION-cookie/m-p/1345451#M460578</guid>
      <dc:creator>dmohanty</dc:creator>
      <dc:date>2017-05-01T19:10:01Z</dc:date>
    </item>
  </channel>
</rss>

