Today i was searching how to set raw coookie in php.PHP provide
setrawcookie() method to set raw cookie in php.In this tutorial i will tell you with simple example which shows how to set a raw cookie.
setrawcookie() is exactly the same as
setcookie()except that the cookie value will not be automatically urlencoded when sent to the browser.
This function is same as
setcookie() method and accept same number of parameters.You can see the php reference manual of
setcookie() function, more details can be found below.
In the following example we are passing 3 parameters.
1) cookie name – its the name by which cookie will be identified.
2) cookie value – its the value stored in cookie.
3) expiration time – the time till the cookie will be available, after that it will be destroyed.
<?php setrawcookie( "cookiename", "cookievalue", time()+3600); ?>
How to get rawcookie value:
1 2 3 4 5 6 7
if(isset($_COOKIE['cookiename'])) $cookieVal = $_COOKIE['cookiename']; else echo "cookies is not set!"; echo "Your cookie value - ". $cookieVal; ?>
Latest posts by Parvez (see all)
- Beginner tutorial : How To Use Filter in angular - July 28, 2015
- Automating AngularJS Build With Grunt - July 13, 2015