<?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 Magic Book - Free PHP Scripts, Tutorials and Downloads &#187; isset</title>
	<atom:link href="http://www.phpmagicbook.com/category/isset/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.phpmagicbook.com</link>
	<description>PHP AtoZ Reloaded, free php tutorials, free php downloads, php scripts, PHP tips</description>
	<lastBuildDate>Tue, 15 Jun 2010 13:22:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Creating And Retrieving Cookies In PHP</title>
		<link>http://www.phpmagicbook.com/php-cookies-create/</link>
		<comments>http://www.phpmagicbook.com/php-cookies-create/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 04:04:30 +0000</pubDate>
		<dc:creator>Hiroshi</dc:creator>
				<category><![CDATA[Cookies]]></category>
		<category><![CDATA[isset]]></category>
		<category><![CDATA[cookie]]></category>
		<category><![CDATA[store]]></category>

		<guid isPermaLink="false">http://www.phpmagicbook.com/?p=189</guid>
		<description><![CDATA[Cookies were invented to allow webmaster&#8217;s to store information about the user and their visit or other information on the user&#8217;s computer. Cookies are not privacy risk. All of the &#8220;trustworthy&#8221; websites use cookies. Creating Cookie &#8211; Last Visit Script &#60;?php //Calculate 60 days in the future //seconds * minutes * hours * days + [...]<p><a href="http://www.phpmagicbook.com/php-cookies-create/">Creating And Retrieving Cookies In PHP</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Cookies were invented to allow webmaster&#8217;s to store information about the user and their visit or other information on the user&#8217;s computer. Cookies are not privacy risk. All of the &#8220;trustworthy&#8221; websites use cookies.</p>
<p><span id="more-253"></span></p>
<h4>Creating Cookie &#8211; Last Visit Script</h4>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">//Calculate 60 days in the future</span>
<span style="color: #666666; font-style: italic;">//seconds * minutes * hours * days + current time</span>
<span style="color: #000088;">$inTwoMonths</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">60</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">60</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">24</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">60</span> <span style="color: #339933;">+</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">setcookie</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'lastVisit'</span><span style="color: #339933;">,</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;G:i - m/d/y&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$inTwoMonths</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h4>Retrieving Cookie</h4>
<p>If your cookie hasn&#8217;t expired yet, you can retrieve it from the user&#8217;s PC using the named $_COOKIE associative array. The name of your stored cookie is the key and will let you retrieve your stored cookie value!</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_COOKIE</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'lastVisit'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000088;">$visit</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_COOKIE</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'lastVisit'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">else</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;You've got some stale cookies!&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Your last visit was - &quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$visit</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><a href="http://www.phpmagicbook.com/php-cookies-create/">Creating And Retrieving Cookies In PHP</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.phpmagicbook.com/captcha-random-image-form-validation/" title="Captcha &#8211; Random Image Form Validation Using PHP">Captcha &#8211; Random Image Form Validation Using PHP</a></li><li><a href="http://www.phpmagicbook.com/isset-function/" title="isset Function in PHP &#8211; Check for any Variable if it is Set or Not in PHP">isset Function in PHP &#8211; Check for any Variable if it is Set or Not in PHP</a></li><li><a href="http://www.phpmagicbook.com/php-flash-based-text-hit-counter/" title="PHP Flash Based Text Hit Counter &#8211; Flash Based Hit Counter Using PHP">PHP Flash Based Text Hit Counter &#8211; Flash Based Hit Counter Using PHP</a></li><li><a href="http://www.phpmagicbook.com/remove-ads-for-registered-users-or-admin-on-wordpress-blog/" title="Remove Ads for Registered Users or Admin on WordPress Blog">Remove Ads for Registered Users or Admin on WordPress Blog</a></li><li><a href="http://www.phpmagicbook.com/php-referrer-http-referrer/" title="PHP Referrer &#8211; HTTP Referrer">PHP Referrer &#8211; HTTP Referrer</a></li><li><a href="http://www.phpmagicbook.com/customizing-wordpress-tags-cloud-a-guide/" title="Customizing WordPress Tags Cloud &#8211; A Guide">Customizing WordPress Tags Cloud &#8211; A Guide</a></li><li><a href="http://www.phpmagicbook.com/php-date-and-time-with-season/" title="PHP Date and Time With Season or Weather Information">PHP Date and Time With Season or Weather Information</a></li><li><a href="http://www.phpmagicbook.com/get-file-size-and-file-type-in-php/" title="Get File Size and File Type In PHP">Get File Size and File Type In PHP</a></li><li><a href="http://www.phpmagicbook.com/upload-max-filesize-large-file-uploads/" title="Upload Max Filesize &#8211; Large File Uploads in PHP">Upload Max Filesize &#8211; Large File Uploads in PHP</a></li><li><a href="http://www.phpmagicbook.com/php-is-not-secure/" title="PHP is Not Secure">PHP is Not Secure</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.phpmagicbook.com/php-cookies-create/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>isset Function in PHP &#8211; Check for any Variable if it is Set or Not in PHP</title>
		<link>http://www.phpmagicbook.com/isset-function/</link>
		<comments>http://www.phpmagicbook.com/isset-function/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 03:49:32 +0000</pubDate>
		<dc:creator>Hiroshi</dc:creator>
				<category><![CDATA[PHP Functions]]></category>
		<category><![CDATA[isset]]></category>

		<guid isPermaLink="false">http://www.phpmagicbook.com/?p=187</guid>
		<description><![CDATA[isset &#8212; Determine whether a variable is set or not! Returns TRUE if var exists; FALSE otherwise. If a variable has been unset with unset(), it will no longer be set. isset() will return FALSE if testing a variable that has been set to NULL. isset() only works with variables as passing anything else will [...]<p><a href="http://www.phpmagicbook.com/isset-function/">isset Function in PHP &#8211; Check for any Variable if it is Set or Not in PHP</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
]]></description>
			<content:encoded><![CDATA[<p>isset &#8212; Determine whether a variable is set or not! Returns TRUE if var exists; FALSE otherwise. If a variable has been unset with unset(), it will no longer be set. isset() will return FALSE if testing a variable that has been set to NULL. isset() only works with variables as passing anything else will result in a parse error. For checking if constants are set use the defined() function.</p>
<p><span id="more-251"></span></p>
<h4>Example</h4>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">session_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'views'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'views'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'views'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">else</span>
    <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'views'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;views = &quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'views'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>The above script is checking that &#8216;views&#8217; or $views variable is set in session or not.</p>
<p><a href="http://www.phpmagicbook.com/isset-function/">isset Function in PHP &#8211; Check for any Variable if it is Set or Not in PHP</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.phpmagicbook.com/php-sessions/" title="PHP &#8211; Sessions">PHP &#8211; Sessions</a></li><li><a href="http://www.phpmagicbook.com/php-explode/" title="PHP &#8211; Explode">PHP &#8211; Explode</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.phpmagicbook.com/isset-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; Sessions</title>
		<link>http://www.phpmagicbook.com/php-sessions/</link>
		<comments>http://www.phpmagicbook.com/php-sessions/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 03:39:57 +0000</pubDate>
		<dc:creator>Hiroshi</dc:creator>
				<category><![CDATA[Sessions]]></category>
		<category><![CDATA[isset]]></category>

		<guid isPermaLink="false">http://www.phpmagicbook.com/?p=182</guid>
		<description><![CDATA[Session support in PHP consists of a way to preserve certain data across subsequent accesses. This enables you to build more customized applications and increase the appeal of your web site. A visitor accessing your web site is assigned a unique id, the session id. This is either stored in a cookie on the user [...]<p><a href="http://www.phpmagicbook.com/php-sessions/">PHP &#8211; Sessions</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Session support in PHP consists of a way to preserve certain data across subsequent accesses. This enables you to build more customized applications and increase the appeal of your web site. A visitor accessing your web site is assigned a unique id, the session id. This is either stored in a cookie on the user side or is propagated in the URL or can be stored in database. A normal HTML website will not pass data from one page to another. In other words, all information is forgotten when a new page is loaded. This makes it quite a problem for tasks like a shopping cart, which requires data (the user&#8217;s selected product) to be remembered from one page to the next.</p>
<p><span id="more-250"></span></p>
<p>Sometimes we store id, name and other information about user in PHP Sessions. A PHP session solves this problem by allowing you to store user information on the server for later use (i.e. username, shopping cart items, etc). However, this session information is temporary and is usually deleted very quickly after the user has left the website that uses sessions.</p>
<p>Sessions work by creating a unique identification (UID) number for each visitor and storing variables based on this ID. This helps to prevent two users&#8217; data from getting confused with one another when visiting the same web page.</p>
<p>We can start, call or retrieve and use or destroy session or session data.</p>
<h4>Starting a PHP Session</h4>
<p>Before you can begin storing user information in your PHP session, you must first start the session. When you start a session, it must be at the very beginning of your code, before any HTML or text is sent.</p>
<p>Below is a simple script that you should place at the beginning of your PHP code to start up a PHP session.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">session_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// start up your PHP session!</span>
<span style="color: #666666; font-style: italic;">// this code must be at the top of web page.</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>This code will register the user&#8217;s session with the server, allow you to start saving user information and assign a UID for that user&#8217;s session.</p>
<h4>Storing A Session Variable</h4>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">session_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'downloads'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// store session data</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Downloads = &quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'donloads'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//retrieve data</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h4>Using PHP issetFunction</h4>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">session_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'views'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'views'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'views'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">else</span>
    <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'views'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;views = &quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'views'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h4>Destroying Sessions</h4>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">session_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">session_destroy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// By this all the session data will be erased and session will be reset, free and empty.</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>OR</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">session_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">session_destroy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$_SESSION</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h4>Selectively Destroying Session Data</h4>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">session_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'downloads'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'userName'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// session_destroy();</span>
<span style="color: #666666; font-style: italic;">// $_SESSION=array();</span>
<span style="color: #666666; font-style: italic;">// By this all the session data will not be lost. Just downloads and userName will be destroyed from session and if other data is ther, it will stay there.</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><a href="http://www.phpmagicbook.com/php-sessions/">PHP &#8211; Sessions</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.phpmagicbook.com/isset-function/" title="isset Function in PHP &#8211; Check for any Variable if it is Set or Not in PHP">isset Function in PHP &#8211; Check for any Variable if it is Set or Not in PHP</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.phpmagicbook.com/php-sessions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 2.341 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-07-30 16:32:26 -->
