What is the purpose of the user_data table? I'm using Drupal 8 and I wonder what the purpose is of the user_data table? How can I can store custom data in that table? In my site, the content of that table is the following.
This table is the backend for the User Data service. The User Data service is used to store data specific to users in the system. 

You can set data like this:

\Drupal::service('user.data')-&gt;set($module, $uid, $key, $value);


Where:

$module = the machine key of your module

$uid = the UID of the user for whom data should be retrieved

$key = a key to identify which data you are storing

$value = the value to be stored

This data can be retrieved with the get() method:

$value = \Drupal::service('user.data')-&gt;get($module, $uid, $key);


$value will be equal to the $value you used when setting the data.