• My hosting provider (DreamHost) uses Varnish and this plugin is stopping from Varnish caching pages because the plugin is setting PHPSESSID for every page. It looks like it’s because on initialisation it calls session_start() — when I comment out that line PHPSESSID is no longer being set.

    Is it possible to make this plugin Varnish friendly? Would that be done by setting it’s own cookie name rather than setting PHPSESSID?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    FYI the problematic code is here:

    // Start Session
    add_action('init', 'srs_start_session', 1);
    function srs_start_session() {
        if(!session_id()) {
            session_start();
        }
    }
    

    That pretty much blows away ALL server side caches, because PHP sessions tells the browser “I am a special, unique, instance and I should not be cached.”

    Which … well … Sucks. It looks like this plugin would need a total rewrite. ??

    Thread Starter rvry

    (@rvry)

    I am exploring another plugin wp-power-stats which looks to be setting it’s own cookie rather than using PHPSESSID and it looks promising. I’m just making sure it’s not too heavy that it slows down WordPress loading times – that’s something I liked about this plugin, it looked very light indeed.

    Strangely when I comment out session_start(), which stops PHPSESSID from being generated, it hasn’t helped Varnish to start caching my website. So whilst it is good if this plugin could be Varnish friendly I need to troubleshoot my own website.

    Plugin Author SandyRig

    (@sandyrig)

    Thank you for highlighting this issue. Creating cookies with PHP also generates PHPSESSID so that might fix the caching issue, so I will try using javascript cookies with ajax.

    PS. Sorry about the late reply, not sure why I don’t get messages for any new topics created here.

    Plugin Author SandyRig

    (@sandyrig)

    “might not fix”

    Plugin Author SandyRig

    (@sandyrig)

    I have removed the php session and added cookie based tracking. Let me know how that works for you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘session_start() setting PHPSESSID for every page’ is closed to new replies.