WP_Query orderby random do not repeat infinite scroll – one loop

I use this solution in my functions.php

 /*------ order ------*/
session_start();

add_filter('posts_orderby', 'edit_posts_orderby');

function edit_posts_orderby($orderby_statement) {

    $seed = $_SESSION["sem"];

        if (empty($seed)) {
          $seed = rand();
          $_SESSION["sem"] = $seed;
        }

        $orderby_statement="RAND(".$seed.')';
        return $orderby_statement;  

}

And additionaly, in the page where you show the posts, in the top of the file, i reset the session variable to can start ordering again random in each reload at this way:

$semilla = rand();

$_SESSION["sem"] = $semilla;

Works for me very well.