NYCPHP Meetup

NYPHP.org

[nycphp-talk] $_SESSION in Static function

Vamsidhar Bethanabatla b.vamsidhar at gmail.com
Thu May 11 06:58:00 EDT 2006


Here is the code for those two functions

/**
   * returns the value for parameter stored in $_SESSION
   * if $escaped is true, the returned value is first
   * escaped using addslashes function before returning
   */
  static function GetSessionParm($param,$escaped=false)
  {
   global $_SESSION;
   if (isset(self::$data["session"]))
    if (array_key_exists($param, self::$data["session"]))
     return (($escaped) ? addslashes(self::$data["session"][$param]) :
self::$data["session"][$param]);
    else
     return null;
   else
    return null;
  }

  /**
   * sets a value in session
   */
  static function SetSessionParm($param,$value)
  {
   global $_SESSION;
   $_SESSION[$param] = $value;
   self::$data["session"] = $_SESSION;
  }

if I remove the global $_SESSION the session data isnot being maintaned from
page to page
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20060511/1dd6a60e/attachment.html>


More information about the talk mailing list