• Resolved fizzers

    (@fizzers)


    Hello,

    After experiencing issues with caching, we identified the PHPSESSID cookie is being set by Code Snippets.

    It’s causing a caching issue because whenever Cloudflare sees a custom cookie in the response header, it thinks that the page content might be dependent on the cookie value and therefore does not cache the page.

    How does your plugin use this cookie and is it safe to disable it?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    Code Snippets doesn’t use this cookie. If it’s tied to the plugin, then it would be due to one of your active snippets.

    Thread Starter fizzers

    (@fizzers)

    Hi @bungeshea,

    edit: I was able to track down the individual snippet and then the function that was responsible for setting the cookie – I guess I’ll have to find a different way to enable a random sort function on the store!

    session_start();
    add_filter( 'posts_orderby', 'pips_rand_order_with_seed' );
    function pips_rand_order_with_seed( $orderby ){
    	if( !is_shop() ) return $orderby;
    	// do the magic only when "Sort in a random order" is selected
    	if( isset( $_GET['orderby'] ) && 'rand' === $_GET['orderby'] ) {
    		// reset the order each time the 1st page is visited
    		if( ! is_paged() && isset( $_SESSION['seed'] ) ) {
    			unset( $_SESSION['seed'] );
    		}
    		$seed = false;
    		if( isset( $_SESSION['seed'] ) ) {
    			$seed = $_SESSION['seed'];
    		}
    		// Set a new seed if not exists
    		if ( ! $seed ) {
    			$seed = rand();
    			$_SESSION['seed'] = $seed;
    		}
    		// pass it to an SQL query
    		$orderby = 'RAND(' . $seed . ')';
    	}
    	return $orderby;
    }

    Thank you for your help.

    • This reply was modified 3 years ago by fizzers.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PHPSESSID cookie being set’ is closed to new replies.