php - how to make session_start change on each refresh -


im using below code on wordpress display posts randomly not duplicate them. works apart when refresh page stays same is. way change displayed clear cache , cookie. possible make on each refresh changes?

here code:

session_start();  add_filter('posts_orderby', 'edit_posts_orderby');  function edit_posts_orderby($orderby_statement) {      $seed = $_session['seed'];     if (empty($seed)) {       $seed = rand();       $_session['seed'] = $seed;     }      $orderby_statement = 'rand('.$seed.')';     return $orderby_statement; } 

remove if condition, in current situation - rand option set if session empty. working @ first time i.e session not set.

  $seed = rand();   $_session['seed'] = $seed; 

instead of

if (empty($seed)) {   $seed = rand();   $_session['seed'] = $seed; } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -