I'm trying to store a cookie for the language that the user wants. For some reason. It calls this class at the beginning of every page. For some reason, it doesn't set the cookie variable as I do var_dump() on it, it just returns NULL. Any ideas? I'd appreciate a tip.
Here is class file.
class LanguageSession {
var $languageId;
var $cookieArray = array();
function LanguageSession( $languageId ) {
$this->setLanguageId( $languageId );
}
function setLanguageId( $languageId ) {
if( $languageId == LS_ENGLISH || $languageId == LS_FRENCH ) {
$this->languageId = $languageId;
} else {
$this->readCookie();
}
}
function readCookie() {
// get cookie variable
global $language;
if( isset( $language ) && !empty( $language ) ) {
$this->languageId = $language;
} else {
$this->languageId = LS_ENGLISH;
}
$this->remember();
}
function remember() {
setcookie( 'language', $this->languageId, time() + 3600 );
}