[nycphp-talk] $_SESSION in Static Methods
Vamsidhar Bethanabatla
b.vamsidhar at gmail.com
Fri May 12 11:15:33 EDT 2006
Hi Flav,
Your views regarding the class have been very helpful to me. I designed this
wrapper class in a very absurd manner. I was learning by expermenting in
developing wrapper classes and eventually and very regretfully I also
implemented it in a live environment (my mistake). Your point is right in
case the 'data' member is not filled prior to calling GetSessionParm(). This
is how I Use this class
There is an Initialization procedure common to all pages in another utility
class called page.class.php. Following is a snippet from it.
//Set session timeout to 2hrs
ini_set('session.gc_maxlifetime', 2*60*60);
if (!session_id())
session_start();
self::$formDataObj = new HttpRequest();
The constructor of HttpRequest says
function __construct()
{
$this->SetFormData();
}
and the SetFormData is like this
/**
* This function get the information from
* POST,GET,REQUEST and SESSION arrays and stores
* it in the object's data attribute
*/
public function SetFormData($data = null)
{
global $_SESSION;
if(null == $data)
{
self::$data["post"] = isset($_POST) ? $_POST : null;
self::$data["get"] = isset($_GET) ? $_GET : null;
self::$data["request"] = isset($_REQUEST) ? $_REQUEST : null;
self::$data["session"] = isset($_SESSION) ? $_SESSION : null;
}
else
{
self::$data = $data;
}
}
when GetSessionParam is called the session data should have been set into
the data member varible.
Pl. let me know if there is again any critical prob. in this code. This code
has worked without any 'global' declartion on two of our installations one
local(windows) and other live (linux) but when the server was shifted
somehow the user was not able to login to the system. When I tracked the
prob. it came to be that after validating the user the system puts an object
in the session indicating the validity and this object is not available on
another page using GetSessionParm.
The prob. is somewhere in this classs itself because $_SESSION alone works
fine.
your notes regarding use of addslashes had been very informative for me. I
am thankful to you.
(I still wonder why I created a constructor to fill static data :) )
Regards,
Vamsi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20060512/161dfc0b/attachment.html>
More information about the talk
mailing list