PHP: How to Set a Raw Cookie?

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.
Manual Rawcookie

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:

	$cookieVal = $_COOKIE['cookiename']; 
	echo "cookies is not set!";

echo "Your cookie value - ". $cookieVal;
The following two tabs change content below.
Hi, This is Parvez Alam from India. I am software developer with 6 years’ experience in web development. I have submitted articles on PHP, Mysql, Magento,CSS, HTML, jQuery, web designing and social API. You can subscribe to my blog via RSS/Twitter/Google plus and Facebook. parvez1487(at)gmail(dot)com