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;

Support US!,Subscribe Our Mailing List

Subscribe our newsletter and get awesome free article Updates and Demos.

Recommended For You
phpflow is web programming blog.The Articles and Tutorials focused on PHP Programming, Jquery Example,Jquery Plugin,Jquery Demos,Jquery Website,Web
Difference Between Sort and Asort in PHP

In this tutorial i will tell you difference between sort() and asort() php function.Basicly this is very common question for...