Php tutorial imitating asp tutorial application Object online count statistics
Usage:
Application ('key', 'value'); // set key = value
$ Value = application ('key'); // obtain the key value
*/
Function application ()
{
$ Args = func_get_args (); // obtain the input parameter
If (count ($ args)> 2 | count ($ args) <1) return;
$ Ssid = session_id (); // Save the current session_id
Session_write_close (); // ends the current session
Ob_start (); // disable the global session from sending the header.
Session_id ("xxx"); // register global session_id
Session_start (); // enable global session
$ Key = $ args [0];
If (count ($ args) = 2) // if the second parameter exists, it indicates that the global session is written.
{
$ Re = ($ _ session [$ key] = $ args [1]);
}
Else // if there is only one parameter, the value corresponding to this parameter is returned
{
$ Re = $ _ session [$ key];
}
Session_write_close (); // end the global session
Session_id ($ ssid); // re-register the non-Global session interrupted above
Session_start (); // restart
Ob_end_clean (); // discard some header output due to session_start.
Return $ re;
}