Can we define PHP session variables in one place? -
can define php session variables in 1 place inside function or variable can use across application?
like this:
$abc=$_session['my_session']; $abc['name']='john';
please read on references in php basic question.
//ensure my_session exists , array $_session['my_session'] = isset($_session['my_session']) ? $_session['my_session'] : array(); //assign reference $abc = &$_session['my_session']; $abc['name'] = 'john';
note $abc
available in current scope, use inside function you'll have use global
keyword. that's bit "dirty" should use functions instead of this.
Comments
Post a Comment