<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>php Cookies Archives -</title>
	<atom:link href="https://mitindia.in/tag/php-cookies/feed/" rel="self" type="application/rss+xml" />
	<link>https://mitindia.in/tag/php-cookies/</link>
	<description></description>
	<lastBuildDate>Sat, 26 Nov 2016 06:50:40 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://mitindia.in/wp-content/uploads/2023/03/cropped-android-chrome-512x512-1-32x32.png</url>
	<title>php Cookies Archives -</title>
	<link>https://mitindia.in/tag/php-cookies/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>PHP Function, Cookies, Session examples</title>
		<link>https://mitindia.in/php-function-cookies-session-examples/</link>
					<comments>https://mitindia.in/php-function-cookies-session-examples/#comments</comments>
		
		<dc:creator><![CDATA[SKB]]></dc:creator>
		<pubDate>Sat, 18 Jun 2016 09:21:28 +0000</pubDate>
				<category><![CDATA[PHP-MySQL]]></category>
		<category><![CDATA[php Cookies]]></category>
		<category><![CDATA[PHP FunctionPHP Function]]></category>
		<category><![CDATA[Session]]></category>
		<guid isPermaLink="false">http://www.mitindia.in/?p=76</guid>

					<description><![CDATA[<p>1. PHP Program to use of user-defined function. &#60;?php function msg() { echo "Hello from msg function!"; } function test() { echo "Hello from test function!"; } test(); echo "&#60;hr&#62;"; msg(); ?&#62; Output of above code is&#8230; 2. PHP Program to use of function with parameters. &#60;?php function add($a, $b) { $c=$a+$b; echo "sum=", $c; [&#8230;]</p>
<p>The post <a href="https://mitindia.in/php-function-cookies-session-examples/">PHP Function, Cookies, Session examples</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>1. PHP Program to use of user-defined function.</p>
<pre>&lt;?php
function msg()
{
echo "Hello from msg function!";
}

function test()
{
echo "Hello from test function!";
}

test();
echo "&lt;hr&gt;";
msg();
?&gt;</pre>
<p>Output of above code is&#8230;</p>
<div class="separator"><img fetchpriority="high" decoding="async" class="alignnone" title="function without parameter" src="https://1.bp.blogspot.com/-3wh70HteKR4/VxdU2zNk4PI/AAAAAAAABYw/RC-SSsoFr1A2S4xYvrkuri6OkzBq1G0CACLcB/s1600/function.JPG" alt="function without parameter" width="385" height="190" border="0" /></div>
<p>2. PHP Program to use of function with parameters.</p>
<pre>&lt;?php
function add($a, $b)
{
$c=$a+$b;
echo "sum=", $c;
}
add(2,5);
?&gt;</pre>
<p>3. PHP Program to create cookies.</p>
<pre>&lt;html&gt;
   &lt;head&gt;
    &lt;title&gt;Set Cookies&lt;/title&gt;
   &lt;/head&gt;

&lt;?php
setcookie("username", "Raj", time()+120, "/","", 0);
setcookie("age", "50", time()+120, "/", "",  0);
setcookie("country", "India", time()+120, "/", "",  0);
?&gt;
   
  &lt;body&gt;
    &lt;?php echo "Setting Cookies..." ?&gt;
   &lt;/body&gt;
   
&lt;/html&gt;</pre>
<p><img decoding="async" class="alignnone" title="setting cookies" src="https://1.bp.blogspot.com/-qiKXMwQggCg/VxdWYhI4kUI/AAAAAAAABZA/wBH3CadD4PENM-VJAiNkkgY8mkOx9ksIwCLcB/s1600/setck.JPG" alt="setting cookies" width="312" height="105" border="0" /></p>
<p>4. PHP Program to retrieve cookies values [from above program]</p>
<pre>  &lt;?php
echo "&lt;h1&gt;Fetching Cookies Value &lt;/h1&gt;";
         echo $_COOKIE["username"]. "&lt;br&gt;";
         echo $_COOKIE["age"] . "&lt;br&gt;";
         echo $_COOKIE["country"] . "&lt;br&gt;";
      ?&gt;</pre>
<p><img decoding="async" class="alignnone" title="fetching cookies values" src="https://4.bp.blogspot.com/-YOA-BJ7S0rI/VxdWC915JBI/AAAAAAAABY8/JQjM2rJssb40-aNr5Qp8GOBbUGoDNkjsQCLcB/s1600/ret.JPG" alt="fetching cookies values" width="416" height="165" border="0" /></p>
<p>5. PHP Program to retrieve server information using super global variables.</p>
<pre>&lt;?php 
echo "&lt;h1&gt; PHP Superglobal variables &lt;/h1&gt;"; 
echo "Location:",$_SERVER['SERVER_NAME'];
echo "&lt;br&gt;";
echo "Port number:",$_SERVER['HTTP_HOST'];
echo "&lt;br&gt;";
echo "Browser info:", $_SERVER['HTTP_USER_AGENT'];
echo "&lt;br&gt;";
echo "File name:", $_SERVER['SCRIPT_NAME'];
?&gt;</pre>
<p>Output of the program is&#8230;</p>
<div class="separator"><img loading="lazy" decoding="async" class="alignnone" title="superglobal-variables" src="https://2.bp.blogspot.com/-jY2xfWWnm1Y/VxdXGBhzy5I/AAAAAAAABZI/XkhJ2oVCw18WMOSrBLrw8ys1V8YHIpKygCLcB/s1600/superglobal-variables.JPG" alt="superglobal-variables" width="624" height="247" border="0" /></div>
<p>6. PHP Program to use of SESSIONS.</p>
<pre>&lt;?php
   session_start();
   if( isset( $_SESSION['c'] ) ) 
{
 $_SESSION['c'] += 1;
}

else
{
$_SESSION['c'] = 1;
}
    
 $msg = "You are visitor number : ". $_SESSION['c'];
?&gt;
&lt;?php  echo ( $msg ); ?&gt;</pre>
<p>Above program produces following output.</p>
<div class="separator"><img loading="lazy" decoding="async" class="alignnone" title="session-examples" src="https://3.bp.blogspot.com/-MJzqpewdxY4/VxdXy6Yo3wI/AAAAAAAABZQ/9qYZZyH9SngW_WHDraahOdYx__ddUKEJwCLcB/s1600/session-examples.JPG" alt="session-examples" width="310" height="83" border="0" /></div>
<p>7. PHP example to demonstrate destroy the sessions.</p>
<pre>&lt;?php
session_start();
session_destroy();
echo "&lt;h1&gt; Session destroyed!&lt;/h1&gt;";
?&gt;</pre>
<p>And the output is&#8230;</p>
<div class="separator"><img loading="lazy" decoding="async" class="alignnone" title="session destroyed " src="https://2.bp.blogspot.com/-CAxJMDE2thI/VxdYTs0bA8I/AAAAAAAABZc/H0FzN_8IoHgrN0mcx_k0wOpwwPQnDXGagCLcB/s1600/session_destroy.JPG" alt="session destroyed " width="386" height="94" border="0" /></div>
<p>&nbsp;</p>
<p><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Fmitindia.in%2Fphp-function-cookies-session-examples%2F&amp;linkname=PHP%20Function%2C%20Cookies%2C%20Session%20examples" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fmitindia.in%2Fphp-function-cookies-session-examples%2F&amp;linkname=PHP%20Function%2C%20Cookies%2C%20Session%20examples" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fmitindia.in%2Fphp-function-cookies-session-examples%2F&#038;title=PHP%20Function%2C%20Cookies%2C%20Session%20examples" data-a2a-url="https://mitindia.in/php-function-cookies-session-examples/" data-a2a-title="PHP Function, Cookies, Session examples"><img src="https://static.addtoany.com/buttons/favicon.png" alt="Share"></a></p><p>The post <a href="https://mitindia.in/php-function-cookies-session-examples/">PHP Function, Cookies, Session examples</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mitindia.in/php-function-cookies-session-examples/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
