title: Setting session variable in php through jquery click event
body: <p>So I have been looking at all possible answers so far on Stackoverflow. But no matter how I try, I can't get this to work.</p>
  
  <p>I'm trying to set a sessionvariable according to a clicked linked.</p>
  
  <p>this can be 'grid' or 'list'</p>
  
  <p>I can change the class, and the view of the corresponding div. However, my $.post call to php is not passing the variable ( im assuming this, since nothing happens ) or my php call is wrong.</p>
  
  <p>Here's my code:</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;li class="display-control-list-item" &gt; &lt;a href="javascript: void(0)" class="js-set-display list" id="list" &gt; Listview &lt;/a&gt; &lt;/li&gt;
  &lt;li class="display-control-list-item" &gt; &lt;a href="javascript: void(0)" class="js-set-display grid" id="grid" &gt; Gridview &lt;/a&gt; &lt;/li&gt;
  </code></pre>
  
  <p>JQUERY</p>
  
  <pre><code> function set_display_type( type ) {
     if ( type == 'grid' ) {
       $( '.js-set-display.list' ).removeClass( 'active' );
       $( '.js-set-display.grid' ).addClass( 'active' );
       $( '.content-inner' ).attr({ 'class' : 'container content-inner gridview' });
       var view = 'gridview';
       $.post( 'library/fx.behaviour.php' , { setdisplay: view });
     }
     if ( type == 'list' ) {
       $( '.js-set-display.grid' ).removeClass( 'active' );
       $( '.js-set-display.list' ).addClass( 'active' );
       $( '.content-inner' ).attr({ 'class' : 'container content-inner listview' });
       var view = 'listview';
       $.post( 'library/fx.behaviour.php' , { setdisplay: view });
     }
   }
  </code></pre>
  
  <p>and my PHP in fx.behaviour.php</p>
  
  <pre><code>$_SESSION[ 'display' ] = 'listview'; // set default
  if ( $_POST[ 'setdisplay' ] != '' ) {
    $view = $_POST[ 'setdisplay' ];
    $_SESSION[ 'display' ] = $view;
  }
  </code></pre>
  
  <p>In short: the sessionvariable won't update after clicking the url and passing the value through jquery to php.</p>