[eluser]rainmanx[/eluser]
Hi guys, long time no see.
I searched through the forum for a solution to this, but I couldn't find any. It may seem a childish question, but please bare with me.
I need to test if cookies are enabled on the user's machine, in order to warn him that the functionality of the app is limited unless he will enable them (for instance, I use cookies to store the language preference and to make this preference persistent).
So, I came up with this:
Code:
$this->session->set_userdata('cookies_enabled', 'some_test_value');
$c_enabled = $this->session->userdata('cookies_enabled');
if (!$c_enabled) {
echo 'You must enable cookies for the application to work properly.';
}
The code above could be part of, let's say, the default controller; it doesn't really matter. Logically, this code would produce a FALSE value for $c_enabled if cookies are disabled (my thinking is that the app is trying to read a value previously written in the cookie and if this fails, the return value is FALSE).
BUT, regardless of cookies being enabled or not, $c_enabled always has the right value (e.g. 'some_test_value').
Maybe this is not the best practice for testing if cookies are enabled or not. It definitely doesn't work and I don't know why.
If anyone has a solution to this or another approach that works, thanks in advance.