CHttpSession

Namesession
ClassCHttpSession
Location/home/vhosts/app-manager.eu5.org/framework/web/CHttpSession.php
CHttpSession provides session-level data management and the related configurations.

To start the session, call {@link open()}; To complete and send out session data, call {@link close()}; To destroy the session, call {@link destroy()}. If {@link autoStart} is set true, the session will be started automatically when the application component is initialized by the application. CHttpSession can be used like an array to set and get session data. For example,
  $session=new CHttpSession;
  $session->open();
  $value1=$session['name1'];  // get session variable 'name1'
  $value2=$session['name2'];  // get session variable 'name2'
  foreach($session as $name=>$value) // traverse all session variables
  $session['name3']=$value3;  // set session variable 'name3'
The following configurations are available for session:
  • {@link setSessionID sessionID};
  • {@link setSessionName sessionName};
  • {@link autoStart};
  • {@link setSavePath savePath};
  • {@link setCookieParams cookieParams};
  • {@link setGCProbability gcProbability};
  • {@link setCookieMode cookieMode};
  • {@link setUseTransparentSessionID useTransparentSessionID};
  • {@link setTimeout timeout}.
See the corresponding setter and getter documentation for more information. Note, these properties must be set before the session is started. CHttpSession can be extended to support customized session storage. Override {@link openSession}, {@link closeSession}, {@link readSession}, {@link writeSession}, {@link destroySession} and {@link gcSession} and set {@link useCustomStorage} to true. Then, the session data will be stored and retrieved using the above methods. CHttpSession is a Web application component that can be accessed via {@link CWebApplication::getSession()}.

Options

Displaying 1-10 of 10 results.
NameValueDescriptionType
autoStarttrueWhether the session should be automatically started when the session application component is initialized, defaults to true.boolean
behaviorsarray()The behaviors that should be attached to this component. The behaviors will be attached to the component when {@link init} is called. Please refer to {@link CModel::behaviors} on how to specify the value of this property.array
sessionIDnullThe session ID for the current sessionstring
sessionNamenullThe session name for the current session, must be an alphanumeric string, defaults to PHPSESSIDstring
savePathnullThe current session save path @throws CException if the path is not a valid directorystring
cookieParamsnullSets the session cookie parameters. The effect of this method only lasts for the duration of the script. Call this method before the session starts. cookie parameters, valid keys include: lifetime, path, domain, secure. @see http://us2.php.net/manual/en/function.session-set-cookie-params.phparray
cookieModenullHow to use cookie to store session ID. Valid values include 'none', 'allow' and 'only'.string
gCProbabilitynullThe probability (percentage) that the gc (garbage collection) process is started on every session initialization. @throws CException if the value is beyond [0,100]integer
useTransparentSessionIDnullWhether transparent sid support is enabled or not.boolean
timeoutnullThe number of seconds after which data will be seen as 'garbage' and cleaned upinteger