AVEbrahimi
AVEbrahimi

Reputation: 19134

Set temporary variables for current logged in user in WordPress

If my user can login from different browsers, concurrently, how can I save a temporary variable (a special format random variable or a device specific id) for each session and access it later in codex?

I can't use update_user_meta and get_user_meta, because user meta is user based, not session based.

Upvotes: 0

Views: 393

Answers (1)

user2985710
user2985710

Reputation: 153

You could use user meta.

See update_user_meta and get_user_meta.

The current user id can be retrieved with get_current_user_id to set and then get values associated with a given user.

The only gotcha is when using get_user_meta (or any other get meta function in WordPress), is be sure to set $single to true, otherwise you'll get an array with just one value.

Upvotes: -1

Related Questions