Support » Plugins » Hacks » Should i use Transient API or Cookies?

  • So im making a plugin, that relied on SESSION data.. Which i just now figured out is not working in WordPress..

    So as an alternative i would have used cookies, but came accross the Transient API in WordPress..

    Now i cannot decide which to use..

    What are the pros and cons on each of them ?

Viewing 2 replies - 1 through 2 (of 2 total)
  • I’ve used transients before. They are very easy to work with (easier then cookies really) so I’d suggest using them.

    Moderator bcworkz

    (@bcworkz)

    The important difference is cookies are stored on a user’s browser, transients on your server. If you have a lot of user data, the number of transients can grow quite large. But with cookies, you lose some control of the data, the user can refuse or corrupt cookies, not so with transients.

    Transients can be managed per user (or not). Cookies are really per browser, not user. The same user on a different browser makes previous cookies inaccessible. Cookies add to the HTTP data transmitted whether you need them or not, transients come in over the DB connection, but only if you need them.

    Depending on the nature of your data, one form or the other will make more sense. It’s likely you’ll find the need to use both. It’s foolish to arbitrarily use one or the other without considering which is the best use for the data at hand.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Should i use Transient API or Cookies?’ is closed to new replies.