Adding custom user session info in plugin (2 posts)

  1. Levander
    Posted 10 years ago #

    I want to add a small piece of data to be associated with each specific user reading my blog for this plugin I'm writing.

    This piece of data is really just a flag, so could possibly even be added to the cookie. But, later (like a year later) I'm going to want to add a few more pieces of data, so maybe not.

    Am wondering if wordpress has any capabilities builtin to support this? I've seen get_userdata and get_currentuserinfo, but it looks like these operated on hard coded variables. And you can't add your own.

    Should I look into implementing something from scratch based on PHP's own user session capabilities?

  2. ketsugi
    Posted 10 years ago #

    Why not just store it as an array:

    Array (
    "user_id" => 3,
    "my_option" => true,
    "my_other_option" => "buggaboo"

    then serialize it and chuck it in as an option using add_option()

Topic Closed

This topic has been closed to new replies.

About this Topic