<?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>Solid State Raam &#187; PHP</title>
	<atom:link href="http://solidstateraam.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://solidstateraam.com</link>
	<description>Explorations (and exploitations) of the digital world by one of its many netizens.</description>
	<lastBuildDate>Thu, 13 May 2010 19:24:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PHP Session Permission Denied Errors with Sub-Domains and IE7 or IE8</title>
		<link>http://solidstateraam.com/php-session-permission-denied-errors-with-sub-domains-and-ie7-or-ie8/</link>
		<comments>http://solidstateraam.com/php-session-permission-denied-errors-with-sub-domains-and-ie7-or-ie8/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 13:23:42 +0000</pubDate>
		<dc:creator>Raam</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Weird]]></category>

		<guid isPermaLink="false">http://solidstateraam.com/?p=493</guid>
		<description><![CDATA[I encountered a strange problem with IE7 and IE8 where if I visited example.com first and then visited sub-domain.example.com, Apache would return Permission Denied errors errors when trying to access the PHP session files for sub-domain.example.com. After some investigation, it appears this is a problem with the way IE7 and IE8 request session data from Apache, or possibly because IE7 and IE8 have a non-standard way of announcing the domain they're requesting session data for.]]></description>
			<content:encoded><![CDATA[<p>I encountered a strange problem with IE7 and IE8 where if I visited example.com first and then visited sub-domain.example.com, Apache would return Permission Denied errors errors when trying to access the PHP session files for sub-domain.example.com.</p>
<p>After some investigation, it appears this is a problem with the way IE7 and IE8 request session data from Apache, or possibly because IE7 and IE8 have a non-standard way of announcing the domain they&#8217;re requesting session data for.</p>
<p>Here&#8217;s my scenario:</p>
<p>I&#8217;m running Apache 1.3 with two domains, each has their own account with their own users:</p>
<pre class="brush: plain;">
    Domain: mycompany.com
    Session path: /tmp/
    Webserver user: mycompanycom

    Domain: support.mycompany.com
    Session path: /tmp/
    Webserver user: nobody
</pre>
<p>Here is what happens during a normal visit with Firefox/Safari/Chrome:</p>
<ol>
<li>I visit mycompany.com and session file is created in <code>/tmp/</code> owned by the user <code>mycompanycom</code></li>
<li>I then visit support.mycompany.com, and second session file is created in <code>/tmp/</code> owned by user <code>nobody</code></li>
<li>Apache doesn&#8217;t get confused and the correct session files are returned</li>
</ol>
<p>However, here&#8217;s what happens during a visit with IE7 and IE8:</p>
<ol>
<li>I visit mycompany.com and a session file is created in <code>/tmp/</code> owned by the user <code>mycompanycom</code></li>
<li>I then visit support.mycompany.com and, instead of creating second session file in <code>/tmp/</code> owned by the user <code>nobody</code> as you would expect (and as happens when using Firefox/Safari/Chrome), Apache tries to return the session file for mycompany.com. </li>
<li>The session file for mycompany.com is owned by the user <code>mycompanycom</code>, so the web server, running as user <code>nobody</code> cannot access it. Permission is denied.</li>
</ol>
<p>I searched Google for a solution and came across <a href="http://stackoverflow.com/questions/912098/permissions-to-php-session-files/">this question on StackOverflow</a>. Several users suggested creating a separate directory in <code>/tmp/</code> to separate the stored session data for support.mycompany.com from the session data for mycompany.com and then telling PHP to store all session data for support.mycompany.com in the new directory. This worked perfectly!</p>
<p>Here&#8217;s what I did. First, create the new session directory (Note: Make sure the new directory resides inside <code>/tmp/</code>!):</p>
<pre class="brush: bash;">
    mkdir /tmp/support.mycompany.com
    chown nobody:nobody /tmp/support.mycompany.com
</pre>
<p>I then added the following to an <code>.htaccess</code> file in the root web directory for support.mycompany.com:</p>
<pre class="brush: bash;">
    php_value session.save_path '/tmp/support.mycompany.com'
</pre>
<p>And finally, I removed all existing session data in <code>/tmp/</code> to ensure the new session path would get used immediately:</p>
<pre class="brush: bash;">
    rm -f /tmp/sess_*
</pre>
<p>And that&#8217;s it! Now IE7 and IE8 work properly because when visiting support.mycompany.com, IE7 and IE8 do not accidentally find session data for mycompany.com and try to use it.</p>
<p>I&#8217;m fairly certain this problem has to do with how IE7 and IE8 request session data from Apache. They probably first request session data for mycompany.com and THEN request session data for support.mycompany.com, even though the latter was the only doman entered in the address bar.</p>
]]></content:encoded>
			<wfw:commentRss>http://solidstateraam.com/php-session-permission-denied-errors-with-sub-domains-and-ie7-or-ie8/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
