<?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>WebDev77&#187; session variables php</title>
	<atom:link href="http://www.webdev77.com/tag/session-variables-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webdev77.com</link>
	<description>WebDev77, your online source for news, comments and articles on Web Hosting, Internet marketing, SEO techniques and Web development and design.</description>
	<lastBuildDate>Sat, 04 Apr 2009 00:05:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Loosing PHP Session Variables</title>
		<link>http://www.webdev77.com/loosing-php-session-variables/</link>
		<comments>http://www.webdev77.com/loosing-php-session-variables/#comments</comments>
		<pubDate>Sat, 10 Jan 2009 02:45:58 +0000</pubDate>
		<dc:creator>Bogdan Enache</dc:creator>
				<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[loosing session variables]]></category>
		<category><![CDATA[php session variables]]></category>
		<category><![CDATA[session data]]></category>
		<category><![CDATA[session variables php]]></category>

		<guid isPermaLink="false">http://www.webdev77.com/?p=45</guid>
		<description><![CDATA[Loosing Session Variables (PHP $_SESSION) PHP $_SESSION is a PHP &#8220;super-global&#8221; that can store variables across multiple PHP pages/scripts making it a perfect choice for writing &#8220;members area&#8221; code for example. However, the topic of the post is not about what you can do with the PHP session, but what can you do when it [...]]]></description>
			<content:encoded><![CDATA[<h3>Loosing Session Variables (PHP $_SESSION)</h3>
<p><a href="http://ca2.php.net/manual/en/book.session.php" target="_blank">PHP $_SESSION</a> is a PHP &#8220;super-global&#8221; that can store variables across multiple PHP pages/scripts making it a perfect choice for writing &#8220;members area&#8221; code for example. However, the topic of the post is not about what you can do with the PHP session, but what can you do when it doesn&#8217;t work (you are loosing the session variables across pages). See below a few possible situations:</p>
<h3>What to check and how to fix it</h3>
<ol>
<li><b>Session Initialization.</b> &#8211; Check to make sure that your session initialization <i><b>session_start()</b></i> appears on the top of every page where session variables are needed. On the top doesn&#8217;t necessarily means first thing after the < php? tag, but make sure it appears before any HTML output and before actually using the session variables in whatever data processing you're doing.</li>
<li><b>Session Closing.</b> &#8211; How are you moving from page to page? Are you redirecting the user in the middle of a script? I&#8217;m asking this because when a script ends or <i><b>die()</b></i>s, the session is automagically closed and data saved. If a redirect is in place the script might not have a chance to die naturally so the session data is not saved. Fix? Make sure the data is saved before doing the redirect by calling <i><b>session_write_close()</b></i> .</li>
<li><b>php.ini Configuration.</b> &#8211; It&#8217;s a less common situation but it drove me crazy for about one hour before figuring it out. If you modify stuff in your php.ini make sure you know what you&#8217;re doing. Before learning about PHP sessions I was fooling around and in the [Session] section of the php.ini file and I un-commented this line: <i>;session.save_path = &#8220;/tmp&#8221;</i> (took the ; away).  No harm done, right? The session will be saved in the /tmp folder, right? Wrong! The session no longer worked (I was loosing session variables when changing pages). So, check your php.ini file &#8230;</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.webdev77.com/loosing-php-session-variables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

