calculate Cookie Size in PHP -
i wanted read cookie , calculate length on server side using php, can't find direct method so. how achieve task ?
what ?
setcookie("user", "dino babu kannampuzha", time() + 3600); if (isset($_cookie["user"])) { $data = $_cookie["user"]; $serialized_data = serialize($data); $size = strlen($serialized_data); echo 'length : ' . strlen($data); echo "<br/>"; echo 'size : ' . ($size * 8 / 1024) . ' kb'; }
// output
length : 21 size : 0.232 kb
Comments
Post a Comment