I am using session handling using Database. For some webservice calls using RequestHandler I want to stop auto session create for these some certain action of controller
My question: How can I stop auto session start in some actions of the controller? Please note that I defined Auth component in AppController. Is there any way stop session in action? Do I need to use $this->Session->destroy() in action?
Clarification
On each webservice call It creates a new session row in database. but I don't use any session feature in action.i.e. If anybody call 10 times a action it creates 10 sessions. I feel it will create database space and time overhead.
Apply New changes as suggested
Could not get proper result by using this
// overwrite constructClasses() for remove session in certain actions
public function constructClasses() {
// remove the Session from components again here
// either globally or for certain actions
if (in_array($this->action, array('test1','test2'))) {
foreach($this->components as $key => $val){
if($val =='Session'){
unset($this->components[$key]);
}
}
}
parent::constructClasses();
}
But still new session Id created on test1 0r test2 by API Call
// out put of below code.
function beforeFilter() {
pr($this->components);
}
Array
(
[Cookie] =>
[Auth] => Array
(
[loginAction] => Array
(
[controller] => resources
[action] => login
)
[loginRedirect] => Array
(
[controller] => resources
[action] => view
)
[logoutRedirect] => Array
(
[controller] => resources
[action] => login
)
[authenticate] => Array
(
......
)
)
[Security] => Array
(
[csrfExpires] => +1 hour
)
[RequestHandler] =>
)