In some places you have 'lang' and in others it's 'langg'.
On Tue, Apr 9, 2013 at 12:37 AM, Manjunath Reddy <manju16832003@gmail.com> wrote:
Hi All,
I have trouble reading the cookie I have already registered.
This piece code registered selected language by the user and sets the cookie for future reference.
class AppController extends Controller
{
var $components = array('Session', 'Cookie');
function beforeFilter()
{
//echo "Check = ".$this->Cookie->check('livelifedrive');
echo 'Language 2 = '.$this->Cookie->read('langg'); //Here I tried to read the cookie, Its null.
if ($this->_checkLanguage())
$this->redirect($this->referer(), null, true);
}
/*language handling */
function _checkLanguage()
{
//echo $this->name;exit;
if ($this->name == "Switchto") {
$supported_lang = Configure::read('LANGUAGE.supported');
//print_r($supported_lang);
$default_lang = Configure::read('LANGUAGE.default');
//print_r($default_lang);
$lang = null;
//echo $this->name;exit;
//echo 'Language = '.$this->Cookie->read('lang');exit;
if ($this->name == "Switchto"){
$lang = $this->action;
}
if(!$lang){
$lang = $default_lang;
}
// we need the Cookie
//$cookie = & new CookieComponent();
$this->Cookie->name = 'langg';
$this->Cookie->time = '5 Days'; // or '1 hour'
//$this->Cookie->path = '';
//$this->Cookie->domain = 'localhost/caketest';
$this->Cookie->secure = false; //i.e. only sent if using secure HTTPS
$this->Cookie->key = 'livelifedrive';
$this->Cookie->startup("Switchto");
$this->Cookie->write('langg',$lang,false);
$this->Session->write('langg',$lang);
echo 'Language = '.$this->Cookie->read('langg');
//exit;
//echo $this->name;exit;
if($this->name == "Switchto"){
return true;
}
return false;
}
}
}
//Config.php
$config['LANGUAGE'] = array('supported' => array('eng', 'fre'), 'default' => 'eng');
//SwitchtoController.php - Controller
class SwitchtoController extends AppController{
public $name = 'Switchto';
function beforeFilter(){
parent::beforeFilter();
}
}
But I could see the registered Cookies in Chrome debugger, I'm unable to read from CakePHP side.
Thank you,
Manjunath
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment