测试使用setcookie()或 setrawcookie()函数来设置 cookie 的不同
PHP可以用 setcookie()或 setrawcookie()函数来设置 cookie。<?php/** * 测试 使用setcookie()或 setrawcookie()函数来设置 cookie 的不同 ** @author flyer0126 * @since2012/07/26 */$str = '123_,; abc';setcookie('test', $str, time()+60, '/');// value值:123_%2C%3B%20abcsetrawcookie('test1', $str, time()+60, '/');// value值:123_,; abcsetrawcookie('test2', rawurlencode($str), time()+60, '/');// value值:123_%2C%3B%20abcsetrawcookie('test2', encode_cookie_value($str), time()+60, '/');// value值:123_%2C%3B%20abc/** * php cookie value encode function * @param string $value */function encode_cookie_value($value){return strtr($value,array_combine(str_split($tmp=",; \t\r\n\013\014"),array_map('rawurlencode', str_split($tmp))));}
页:
[1]