Back to top

This is an old revision of the document!


Cover API

The file include/sessions.php contains functions to enable interaction with the Cover API.

Most interactions are based on cookies and therefore need an active local instance of the Cover website. If a local instance should be used, it can be configured by setting the Rack configuration options <php>COVER_API_URL</php>, <php>COVER_COOKIE_NAME</php>, <php>COVER_LOGIN_URL</php> and <php>COVER_LOGOUT_URL</php>.

Functions

<php>get_cover_session()</php>
Returns a PHP object with the information about the user that is logged in on the Cover website. Returns <php>null</php> is user is not logged in on the Cover website.

<php>cover_session_logged_in()</php>
Returns <php>true</php> if a user is logged in on the Cover website. Returns <php>false</php> otherwise.

<php>cover_login_url($next_url=null)</php>
Returns a string with the login url of the Cover website and optionally injects the URL the user should be redirected to after logging in.

<php>cover_logout_url($next_url=null)</php>
Analogous to <php>cover_login_url</php>.

<php>cover_session_get_committees()</php>
Returns an associative array of <php>'committee_login' ⇒ 'committee_name'</php> pairs of the committees the user is in, or an empty array if no user is logged in.

<php>cover_session_in_committee($committee_login)</php>
Returns <php>true</php> if the logged in user is a member of the committee. Returns <php>false</php> otherwise or if not user is logged in.

<php>cover_get_json($method, array $data = array(), $use_session = true)</php>
Issues a GET request to a <php>$method</php> of the Cover API.


documentation/rack/reference/sessions.1527344205.txt.gz · Last modified: 2022/04/03 16:00 (external edit)