I am trying to create my own class functions to find out if a client has cookies enabled...i know PHP can... but i noticed how
PHP will set the cookie, but it takes its time and you dont see it untill you reload the page...as it is written in the PHP manual.
Common Pitfalls:
Cookies will not become visible until the next loading of a page that the cookie should be visible for.
how do i get around this problem????
how do i get a quicker answer...
i don't want pages popping up
or out putting values to the screen,
hiding values in hidden textboxes
passing vaules through the search bar
i just want a quick....yes or no passed to my code blocks, so i can execute other control functions
i know Javascript has the navigator.cookieEnabled;
is there a way to pass that navigator.cookieEnabled boolean value to PHP instead?
any help would be great...
Thanks
Code: Select all
class cookie_model {
function is_cookies_enabled(){
if (empty($_COOKIE['test_name'])){
//no cookie has been set
return "false";
exit();
}
else {
//a cookie has been set
return "true";
exit();
}
}
function set_test_cookie(){
//set a test cookie at start of loggin page
//to find if user has cookies enabled
@setcookie("test_name","test",time() + 3600 * 24 * 30 * 12 * 50);
}
function delete_cookie_test(){
@setcookie("test_name","test",time() - 3600 * 24 * 30 * 12 * 50);
}
}