mrickert Posted March 6, 2007 Share Posted March 6, 2007 Probably an easy answer but not sure... Is there a way to get the size of a cookie (in bytes) using PHP? Since most browsers max the length of a cookie at 4k, I need to check for this during a few extreme conditions on my site. I've tried sizeOf but that always gives me a 1. Thanks Link to comment https://forums.phpfreaks.com/topic/41451-get-the-size-of-a-cookie/ Share on other sites More sharing options...
Orio Posted March 6, 2007 Share Posted March 6, 2007 I think strlen() will be close enough... echo strlen($_COOKIE['cookie_name']); Orio. Link to comment https://forums.phpfreaks.com/topic/41451-get-the-size-of-a-cookie/#findComment-200822 Share on other sites More sharing options...
obsidian Posted March 6, 2007 Share Posted March 6, 2007 I think strlen() will be close enough... echo strlen($_COOKIE['cookie_name']); Orio. Take it a step further with mb_strlen(), and you can force the encoding type to one that reflects actual ASCII 1 char == 1 byte ratios. Link to comment https://forums.phpfreaks.com/topic/41451-get-the-size-of-a-cookie/#findComment-200823 Share on other sites More sharing options...
mrickert Posted March 6, 2007 Author Share Posted March 6, 2007 Thanks ya'll I can make that work. CHEERS Link to comment https://forums.phpfreaks.com/topic/41451-get-the-size-of-a-cookie/#findComment-200831 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.