title: How do i store a session array inside jquery variable? Laravel / Jquery
body: <p>I'm trying to store a session array inside a jquery variable.</p>
  
  <p>My code:</p>
  
  <pre><code>&lt;script&gt;
  @if(session()-&gt;has('zoektermen'))
      var zoektermen = '{{ session()-&gt;get('zoektermen') }}';
      console.log(zoektermen);
  @endif
  &lt;/script&gt;
  </code></pre>
  
  <p>Putting in session inside controller:</p>
  
  <pre><code>if(isset($_GET['searchquery'])) {
      $searchquery = $_GET['searchquery'];
  }
  
  if(session()-&gt;has('zoektermen')) {
      session()-&gt;forget('zoektermen');
      session()-&gt;put('zoektermen', $searchquery);
  } else {
      session()-&gt;put('zoektermen', $searchquery);
  }
  </code></pre>
  
  <p>But i'm getting an error because {{ }} expects a string and not an array.</p>
  
  <pre><code>htmlspecialchars() expects parameter 1 to be string, array given
  </code></pre>
  
  <p>What is the correct way to store the array from the session into a JS array?</p>