Yii Framework Forum: Sessions In Files Are Not Save With Chttpsession Extension - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Sessions In Files Are Not Save With Chttpsession Extension Rate Topic: -----

#1 User is offline   AgentSmith 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 12-December 12

Posted 18 December 2012 - 04:41 AM

Hi!

If I extend CHttpSession and overwrite the methods openSession, closeSession, readSession, writeSession, destroySession and gcSession and set useCustomStorage to true. The files sessions are not created in path and user are not login in app!

Class code
class CHttpSessionExt extends CHttpSession{
		
	public function getUseCustomStorage(){
		return true;
	}
	/*
	 *  openSession, closeSession, readSession, writeSession, destroySession and gcSession 
	 * */
	
	public function openSession($savePath, $sessionName){
		Yii::trace( '[CHttpSessionExt][openSession] start '.$savePath.' -> '.$sessionName );	
		return true;		
	}
	
	public function closeSession(){
		Yii::trace( '[CHttpSessionExt][closeSession] start' );		
		return true;
	}
	public function readSession($id){
		Yii::trace( '[CHttpSessionExt][readSession] start '.$id );		
		return true;
	}
	public function writeSession($id, $data){
		Yii::trace( '[CHttpSessionExt][writeSession] start '.$id.' -> '.$data );		
		return true;
	}
	public function destroySession($id){
		Yii::trace( '[CHttpSessionExt][destroySession] start destruction: '.$id );		
		return true;
	}
	
	public function gcSession($maxLifetime){
		Yii::trace( '[CHttpSessionExt][gcSession] start $maxLifetime:'.$maxLifetime );		
		return true;
	}
	
}




Config file
'session'=>array(
	'class' => 'application.components.CHttpSessionExt',
	'autoStart' => true,		
	'savePath' =>  dirname(__FILE__).DIRECTORY_SEPARATOR.'../runtime/sessions'
),


If I comment 'class' key, default session component create session file in my custom path or default path if comment 'savePath' key. How is this possible? What is wrong with my session component?
0

#2 User is offline   AgentSmith 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 12-December 12

Posted 19 December 2012 - 06:30 AM

Ok, finally I understand my error.

If I use custom staroge I must define all process for to save in file, to read file, etc. This functions not define a custom action for to do when open session or delete session (after execute open session, delete session) but are the open session funtion, delete session funtion, etc.

Then, if i want add a action after create or expired session I must define in each funtion all process of save file in path, read file, etc and add my custom functionality.
0

#3 User is offline   manhooei 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 13-September 11

Posted 29 January 2013 - 10:59 AM

View PostAgentSmith, on 19 December 2012 - 06:30 AM, said:

Ok, finally I understand my error.

If I use custom staroge I must define all process for to save in file, to read file, etc. This functions not define a custom action for to do when open session or delete session (after execute open session, delete session) but are the open session funtion, delete session funtion, etc.

Then, if i want add a action after create or expired session I must define in each funtion all process of save file in path, read file, etc and add my custom functionality.



Can you please post the working code ? I want to use custom session file name for my sessions but don't know how ? :( I appreciate your help!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users