[Mapbender-commits] r4095 - trunk/mapbender/lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Jun 23 13:13:45 EDT 2009


Author: uli
Date: 2009-06-23 13:13:45 -0400 (Tue, 23 Jun 2009)
New Revision: 4095

Added:
   trunk/mapbender/lib/class_mapbender_session.php
Log:
new class for the mapbender session handling

Added: trunk/mapbender/lib/class_mapbender_session.php
===================================================================
--- trunk/mapbender/lib/class_mapbender_session.php	                        (rev 0)
+++ trunk/mapbender/lib/class_mapbender_session.php	2009-06-23 17:13:45 UTC (rev 4095)
@@ -0,0 +1,94 @@
+<?php
+/**
+ * manages the session-handling and the access to session-variables 
+ * @class
+ */
+ 
+ require_once(dirname(__FILE__)."/../http/classes/class_mb_exception.php");
+ 
+ class mapbender_session{
+ 	
+ 	private $id ;
+ 	
+ 	/**
+	 * @constructor
+	 */
+ 	public function __construct() {
+ 		$id = false;
+ 		new mb_notice("session.mapbender_session.instantiated ... ");
+ 	}
+ 	
+ 	/**
+	 * sets the value of the session-variable  
+	 * @param String name the name of the session-variable
+	 * @param Mixed value the new value of the session-variable
+	 */
+ 	public function set($name, $value){
+ 		$this->start();
+ 		$_SESSION[$name] = $value;
+ 		new mb_notice("session.setSessionVariable.set: " . $name ." = ". $value);
+ 		session_write_close(); 
+ 	}
+ 	
+ 	/* pushs the array of the session-variable  
+	 * @param String name the name of the session-variable
+	 * @param Mixed value the new value of the session-variable
+	 */
+ 	public function push($name, $value){
+ 		//not implemented yet
+ 		// todo
+ 	}
+ 	
+ 	/**
+	 * returns the value of the session-variable  
+	 * @param String name the name of the session-variable
+	 */
+ 	public function get($name){
+ 		$this->start();
+ 		if(isset($_SESSION[$name])){
+ 			return $_SESSION[$name];
+ 		}
+ 		else{
+ 			return false;
+ 		}
+ 		session_write_close();
+ 	}
+ 	
+ 	/**
+	 * sets a new session-id   
+	 * @param String id the new id of the session
+	 */
+ 	public function setId($id){
+		$this->id = $id;
+		
+	}
+	
+	/**
+	 * sets a new session-id   
+	 * @param String id the new id of the session
+	 */
+	private function start(){
+		if(session_id() == ''){
+			new mb_notice("session.sessionStart.noActiveId");
+		}
+		if($this->id){
+			session_id($this->id);
+			new mb_notice("session.sessionStart.changeId to: ". session_id());
+		}
+		session_start();
+		new mb_notice("session.sessionStart.id: ". session_id());
+	}
+	
+	/*
+	 * kills the current session
+	 */
+	 public function kill(){
+	 	if (isset($_COOKIE[session_name()])) {
+    	setcookie(session_name(), '', time()-42000, '/');
+		}
+		if(session_id()){
+			session_destroy();
+		}
+	 } 	
+ }
+?>



More information about the Mapbender_commits mailing list