My plugin requires me to save query data for some time. The data isn't big as such; just a couple of search parameters entered by the user so that I can use them across pagination.
I've figured out following ways to do this:
Setting up
session_start()
either in wp_config OR hooking it up to 'init' and then storing my data in$_SESSION
. Then destroying the session when user logs outUsing either
set_transient
orwp_cache_set
; which will store the data in the database; but with expiration time. Of course, I can have my code delete the transient to avoid bloat in the database.
Question: Are the transients shared by all the users visiting a site? So let's say user1 sets transient data; will it be available to user2?
- Use Cookies. This perhaps is the same as using
$_SESSION
; but I'm wondering if there'd be any security issues with this.
Which approach do you suggest? If there's any other more efficient approach - I'd like to know about it as well.
Thank you in advance!
Everyone seems to misunderstand how transient expiration works, so the long and short of it is: transient expiration times are a maximum time. There is no minimum age. Transients might disappear one second after you set them, or 24 hours, but they will never be around after the expiration time.