I'm wondering if I can delete all my website's cookies when a user click on logout, because I used this as function to delete cookies but it isn't work properly:
setcookie("user",false);
Is there a way to delete one domain's cookies in PHP?
I'm wondering if I can delete all my website's cookies when a user click on logout, because I used this as function to delete cookies but it isn't work properly:
setcookie("user",false);
Is there a way to delete one domain's cookies in PHP?
Try using setcookie with a a path specified, this used to catch me out, as it assumes the current path by default. Using / will make the cookie work for the whole domain
setcookie("Username", $username, time()+3600*24*30, '/');
<?php
$cookie_name = "test";
$cookie_value = "123";
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day
?>
You need to write your php code like this
You can use this script If u can want particular cookie
<script>
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1);
if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
}
return "";
}
console.log(getCookie('test'));
<script>
function getSubclassesOf($parent) {
$result = array();
foreach (get_declared_classes() as $class) {
if (is_subclass_of($class, $parent))
$result[] = $class;
}
return $result;
}
Coincidentally, this implementation is exactly the one given in the question linked to by Vadim.
Using the in-php-array-is-the-duct-tape-of-the-universe way :P
function get_all_substrings($input, $delim = '') {
$arr = explode($delim, $input);
$out = array();
for ($i = 0; $i < count($arr); $i++) {
for ($j = $i; $j < count($arr); $j++) {
$out[] = implode($delim, array_slice($arr, $i, $j - $i + 1));
}
}
return $out;
}
$subs = get_all_substrings("a b c", " ");
print_r($subs);
PHP setcookie()
Taken from that page, this will unset all of the cookies for your domain:
http://www.php.net/manual/en/function.setcookie.php#73484