title: Adding item to session on click
body: <p>Using Laravel, in the following scenario, how can I add the book id to the session?</p>
  
  <pre><code>@foreach( $books as $book )
      &lt;li&gt;
          {{ $book-&gt;name }}
          &lt;a href="#" onClick='addBookToList( "&lt;?= $book-&gt;id ?&gt;" )'&gt;Add Book To List&lt;/a&gt;
      &lt;/li&gt;
  @endforeach
  </code></pre>
  
  <p>Here's my attempt. I know that it is not supposed to work this way, but how do I need to change it?</p>
  
  <pre><code>&lt;script&gt;
  function addBookToList( bookId )
  {
      &lt;? Session::put( 'bookId', bookId ); ?&gt;
  }
  &lt;/script&gt;
  </code></pre>