HRDIODB
[ class tree: HRDIODB ] [ index: HRDIODB ] [ all elements ]

Source for file session_class.php

Documentation is available at session_class.php

  1. <?php
  2. /**
  3.  * Session class.
  4.  * This file contains the session class.
  5.  * @package HRDIODB
  6.  */
  7.  
  8. /**
  9.  * This file is part of HRDIODB.
  10.  *
  11.  * HRDIODB is free software; you can redistribute it and/or modify
  12.  * it under the terms of the GNU General Public License as published by
  13.  * the Free Software Foundation; either version 2 of the License, or
  14.  * (at your option) any later version.
  15.  *
  16.  * HRDIODB is distributed in the hope that it will be useful,
  17.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19.  * GNU General Public License for more details.
  20.  *
  21.  * You should have received a copy of the GNU General Public License
  22.  * along with HRDIODB; if not, write to the Free Software
  23.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24.  */
  25.  
  26. /** Common class */
  27. require_once("common_class.php");
  28.  
  29. /**
  30.  * HRDI session class.
  31.  * The session class is used to store and retrieve session data.
  32.  * @package HRDIODB
  33.  */
  34. class session {
  35.   /**
  36.    * Constructor.
  37.    * The session class constructor. If a session hasn't been started yet, it
  38.    * starts a new, named session.
  39.    */
  40.   function session({
  41.     if (!session_id()) {
  42.       session_name("hrdiodb");
  43.       session_start();
  44.     }
  45.   }
  46.  
  47.   /**
  48.    * Sets a session variable.
  49.    * A setter method to store a value in a session variable.
  50.    * @param string $key Session variable name
  51.    * @param mixed $value Session variable value
  52.    */
  53.   function set_var($key$value{
  54.     $_SESSION[$key$value;
  55.   }
  56.  
  57.   /**
  58.    * Gets a session variable.
  59.    * A getter method to retrieve the value of a session variable.
  60.    * @param string $key Session variable name
  61.    * @return mixed Session variable value
  62.    */
  63.   function get_var($key{
  64.     return @$_SESSION[$key];
  65.   }
  66.  
  67.   /**
  68.    * Unsets a session variable.
  69.    * A method to unset a session variable.
  70.    * @param string $key Session variable name
  71.    */
  72.   function unset_var($key{
  73.     unset($_SESSION[$key]);
  74.   }
  75.  
  76.   /**
  77.    * Return to last visited page.
  78.    * This method redirects the user to the last saved page. It makes the
  79.    * magic of "returning to your previous page" possible.
  80.    */
  81.   function go_to_last_page({
  82.     if ($page $this->get_var("page")) {
  83.       common::redirect("$page");
  84.     else {
  85.       common::redirect("index.php");
  86.     }
  87.  
  88.     exit(1);
  89.   }
  90. }
  91. ?>

Documentation generated on Tue, 23 Jan 2007 22:57:52 -0500 by phpDocumentor 1.3.0RC6