function create_session($workflow_id)
{
    global $user;
    $create_new_session = false;
    $_SESSION['workflow_id'] = $workflow_id;
    if (Workflow_Users::doesWorkflowHaveUserName($workflow_id, $user->name)) {
        $apiary_session_base = $user->name . '_' . $workflow_id . '_';
        if (strpos($_SESSION['apiary_session_id'], $apiary_session_base) === false) {
            $create_new_session = true;
        } else {
            if (!Workflow_Sessions::session_id_exists($_SESSION['apiary_session_id'])) {
                $create_new_session = true;
            } else {
                if (!Workflow_Sessions::renew_session($_SESSION['apiary_session_id'])) {
                    $create_new_session = true;
                }
            }
        }
        if ($create_new_session) {
            if (!empty($_SESSION['apiary_session_id'])) {
                if (Workflow_Sessions::session_id_exists($_SESSION['apiary_session_id'])) {
                    Workflow_Sessions::delete($_SESSION['apiary_session_id']);
                }
            }
            $_SESSION['apiary_session_id'] = $apiary_session_base . date("YmdHis");
            Workflow_Sessions::create($_SESSION['apiary_session_id']);
        }
        echo $_SESSION['apiary_session_id'];
    } else {
        echo "false";
    }
}
 static function create($session_id)
 {
     if ($session_id == null || $session_id == '') {
         echo 'A session_id is required.<br>';
         return false;
     }
     if (!Workflow_Sessions::session_id_exists($workflow_name)) {
         $expiration_date = date("YmdHis") + 1000000;
         //add a day to it using the YmdHis format
         $session_expiration = sprintf("%.0f", $expiration_date);
         $insert_record = db_query("INSERT into {apiary_project_workflow_sessions} (session_id, session_expiration)\r\n\t                             VALUES ('%s', '%s')", $session_id, $session_expiration);
         return $insert_record;
     } else {
         echo "Session ID already exists. <br>";
     }
     return false;
 }