Ho to get PHP setrawcookie value back?

Posted by user250343 on Stack Overflow See other posts from Stack Overflow or by user250343
Published on 2010-04-22T18:52:39Z Indexed on 2010/04/22 18:53 UTC
Read the original article Hit count: 418

Filed under:
|
|
|

The IETF recommends to use base64 encoding for binary cookie values. http://tools.ietf.org/html/draft-ietf-httpstate-cookie-07

So I use setrawcookie(..) but I don't know what variable to use to get the cookie back because $_COOKIE[..] still uses the URL decoding that matches setcookie(..). This replaces "+" with " " in the output.

<?php

var_dump($_COOKIE['TEST']);
$binary_string = "";
for($index = 0; $index < 256; $index++){
    $binary_string .= chr($index);
}
$encoded_data = base64_encode($binary_string);
var_dump($encoded_data);
$cookie_set = setrawcookie('TEST', $encoded_data, time() + 3600);

?>

© Stack Overflow or respective owner

Related posts about php5

Related posts about cgi