access variable from multiple pages
-
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.ww.wp.xz.cn/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.
The topic ‘access variable from multiple pages’ is closed to new replies.