0

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.

AVEbrahimi
  • 17,993
  • 23
  • 107
  • 210

1 Answers1

-1

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.

user2985710
  • 153
  • 4
  • user meta is user dependent, not session dependent. – AVEbrahimi Jul 16 '19 at 06:15
  • Can you elaborate more on what you're trying to achieve? Provided the user is logged in on each device, I can't see what could be done with sessions that couldn't be done with user meta. – user2985710 Jul 16 '19 at 16:47