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)
- Bootstrap Data Table – Sorting, Pagination and Filtering Table - December 18, 2014
- textAssist – Smart Auto Text Assistant jQuery Plugin - December 15, 2014
- jQuery Timer – jQuery Pretty Timer Plugin - December 11, 2014