<?php

    /**
     * File for the login action.
     *
     * Implements an action function to be called from the {@see Controller}.
     * 
     * @category Action
     */

    /**
     * Logs the user out and redirects to the login page.
     *
     * Invalidates cookies and session variables.
     * 
     * @param resource $db Database connection. 
     * @return int 0.
     * @category Action
     * @global int The user id.
     */
    function action($db = null){
        global $UID;
        $UID = null;
        setcookie("uid", null, time() - 3600);
        session_regenerate_id();
        $_SESSION['session'] = false;
        $_SESSION['name'] = "";
        $_SESSION['uid'] = "";
        header("Location: /");
        die();
        return 0;
    }
?>

