Your code doesn’t seem to be wrong, it’s just how I would do it – see my answer here. So the question would be is your session getting started? Try debugging this:
// do you have a session id
$s_id = session_id();
print_r($s_id);
// can you declare a bogus session variable, yours might just be empty
$_SESSION['bogus'] = 'bogus';
print_r($_SESSION['bogus']);
Another advisable step is to lower the priority of the add_action()
call:
add_action('init', 'register_session', 1);
just to make sure you have your session ready before it’s needed by another action/function.