Handling Sessions from outside of Piwik?

I am making a plugin that needs a session variable. It is all on the same server and same domain, however I get different session variables in Piwik than I do in let’s say /test.php at the root. I can get and set session variables fine in both and they stay, however they are separate, confirmed by var_dump($_SESSION).

I have ensured session ID remains the same between pages and plugins. I also tried setting the variable by posting to the plugin API feature and got that “working” however it sets the variable for the wrong session (as I should have guessed).

How can I set a session variable from /test.php and have it save in Piwik’s session when I take the user back to the dashboard?

I was able to solve this by using Piwik\Session::start() at the beginning of the API call (and widget renders) and by making the callback URL the URL of the plugin API request. I have done this for log in and log out so it is now all smooth and proper with pure PHP.

Did I miss the documentation on sessions? I looked through all the Piwik documentation (I believe) and was unable to find a reference to Session.