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

Popular posts from this blog

qt - QML MouseArea onWheel event not working properly when inside QML Scrollview -

java - is not an enclosing class / new Intent Cannot Resolve Constructor -

python - Error importing VideoFileClip from moviepy : AttributeError: 'PermissionError' object has no attribute 'message' -