Global parameters that persist forever


I want to show or hide contents of the web page on hyperlink click.

My webpage has a link "Hide content" which on click it changes to "Show Content". Only admins can see this link. If the admin user has set "hide content", the non-admin users can not see the contents on the page and the non-admins can never see the link.

I am trying to achieve this without using the Database, but using a global flag.

I tried using parameters like this:

Yii::app()->params[‘hideContents’] = true;

But the parameter value does not persist across pages.

Is there a way where global parameters can persist forever. Based on this parameter I want to show or hide the contents for the admin and non admin users on the page.

Thanks in advance!



Yii::app()->params[‘paramName’] is set in configuration file and should be available at every part of the website this configuration applies to. Check if the part of website where you cannot call that parameter is using different configuration.

Thanks for the reply.

The set value for the param is accessible. But I want to set new value for the parameter and then want to access the changed value everywhere. The changed value persists only on that page and if I reload the page, the param value from the config is fetched and not the changed value.


Ok, in this case if you don’t want to use DB I suggest session / cookie.

Sessions are per user but what I am looking for is some global setting for all users. Do we have an option like this in Yii?


Yii is build upon PHP. PHP does not support it. Searching the internet comes up with adivises to use a database, a file or memcache.


Great. Yii has it. Under the hood it uses the storing to file, I see.