Advertisement
yur15t

Read/set UTF-8 cookie

Aug 2nd, 2014
545
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.30 KB | None | 0 0
  1. session_start();
  2.  
  3. //writes cookie if not exist and makes session variable with same name
  4. function $setUTF8cookie($name, $val){
  5.     if (!isset($_COOKIE['city'])){     
  6.         setrawcookie($name,$val);
  7.     }
  8.     $_SESSION[$name]= implode('',json_decode('["'.str_replace('%u','\u',$_COOKIE[$cookieName]).'"]'));
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement