Forums

access variable from multiple pages (2 posts)

  1. vanillaxtrakt
    Member
    Posted 2 years ago #

    I wrote a plugin a while back, and needed to store some variable information between pages, so I used PHP sessions. At some point, I realized my WP (it's WPMU, actually) site was slower, so I disabled my plugins one by one. I realized my plugin was causing the performance issues, and I narrowed them down to one line:

    session_start();

    As soon as I commented out that line, my site started working fine again. Of course, this broke my plugin...

    I Googled a bunch for WordPress and PHP sessions, and I saw that many people said they didn't work with WordPress, but nobody saying they worked but caused performance issues.

    So anyway, I looked into other alternatives for doing the same thing. I tried using the WP cache (http://codex.wordpress.org/Function_Reference/WP_Cache), but it seems to dump the data when I try accessing it from another page within my plugin.

    Is this the intended functionality of the WP cache? What other options do I have? Would it be wise to create a new global variable?

    The information only needs to be saved for the user's session while he/she is using the plugin. It doesn't need to be saved in the database.

  2. @mercime
    Member
    Posted 2 years ago #

    I suggest you take this to the WPMU forums - http://mu.wordpress.org/forums/

  3. @mercime
    Member
    Posted 2 years ago #

    I suggest you take this to the WPMU forums - http://mu.wordpress.org/forums/

Topic Closed

This topic has been closed to new replies.

About this Topic