Session Question

hi all, a best way question. :unsure:

what is better?

open the session to the operation and close it. something like this


function foo(){

    	$sesion->open();

    	...

    	//some operations 

    	....

    	$sesion->close();

}

or open the user’s session when the index created the app and close it at the AFTER_REQUEST event.

Just for the info - you don’t have to start session manually, every session method invokes open() automatically.

thk bizley, i didn’t know that :D.

other question :unsure:.

because Yii code \ web \ session :: get () will not close the session after opening it?

while the request is served, Yii never close the session?

You don’t have to close the session if there are no special reasons to do so. See http://php.net/manual/en/function.session-write-close.php