<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: Php session help requested</title>
	<link>http://ask.metafilter.com/15093/Php-session-help-requested/</link>
	<description>Comments on Ask MetaFilter post Php session help requested</description>
	<pubDate>Sun, 13 Feb 2005 16:30:08 -0800</pubDate>
	<lastBuildDate>Sun, 13 Feb 2005 16:30:08 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: Php session help requested</title>
		<link>http://ask.metafilter.com/15093/Php-session-help-requested</link>	
		<description>Php session help requested. [MI] &lt;br /&gt;&lt;br /&gt; Using php 4, my session variables do not want to be passed from page to page. They register fine from a form and are usable on the form&apos;s action page but, otherwise, they are no place to be found.&lt;br&gt;
Suggestions?</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2005:site.15093</guid>
		<pubDate>Sun, 13 Feb 2005 16:27:37 -0800</pubDate>
		<dc:creator>Scottk</dc:creator>
		
			<category>php</category>
		
			<category>sessions</category>
		
			<category>web</category>
		
			<category>programming</category>
		
			<category>scripting</category>
		
	</item> <item>
		<title>By: Scottk</title>
		<link>http://ask.metafilter.com/15093/Php-session-help-requested#259438</link>	
		<description>I store teh variables from a form using the following block:&lt;br&gt;
&lt;br&gt;
        $std_id = $_POST[&apos;std_id&apos;];&lt;br&gt;
	$last = $_POST[&apos;last&apos;];&lt;br&gt;
	$_SESSION[&apos;std_id&apos;] = $std_id;&lt;br&gt;
	$_SESSION[&apos;last&apos;] = $last;&lt;br&gt;
&lt;br&gt;
I can call the set $_SESSION variables on that page only, and not any other pages.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.15093-259438</guid>
		<pubDate>Sun, 13 Feb 2005 16:30:08 -0800</pubDate>
		<dc:creator>Scottk</dc:creator>
	</item><item>
		<title>By: socratic</title>
		<link>http://ask.metafilter.com/15093/Php-session-help-requested#259442</link>	
		<description>Do you have sessions set to auto start in your (I believe) php.ini?  You can also call session_start() if you have a page (or include) that will always be present (or just put it at the top of every page to make sure the session starts).  &lt;br&gt;
&lt;br&gt;
I actually ran into the same problem last night.  Adding session_start() to an include I require() on every page fixed it.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.15093-259442</guid>
		<pubDate>Sun, 13 Feb 2005 16:41:54 -0800</pubDate>
		<dc:creator>socratic</dc:creator>
	</item><item>
		<title>By: Scottk</title>
		<link>http://ask.metafilter.com/15093/Php-session-help-requested#259444</link>	
		<description>Yeah, I have session_start atop every page.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.15093-259444</guid>
		<pubDate>Sun, 13 Feb 2005 16:43:16 -0800</pubDate>
		<dc:creator>Scottk</dc:creator>
	</item><item>
		<title>By: socratic</title>
		<link>http://ask.metafilter.com/15093/Php-session-help-requested#259446</link>	
		<description>Are you accepting cookies in your browser?  Are you blocking cookies with any sort of firewall or proxy solution (like privoxy)?  (ran into that one once too.. almost punched myself in the face for it.. :) )</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.15093-259446</guid>
		<pubDate>Sun, 13 Feb 2005 16:49:37 -0800</pubDate>
		<dc:creator>socratic</dc:creator>
	</item><item>
		<title>By: Scottk</title>
		<link>http://ask.metafilter.com/15093/Php-session-help-requested#259447</link>	
		<description>Hah. That&apos;s a negative.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.15093-259447</guid>
		<pubDate>Sun, 13 Feb 2005 16:50:43 -0800</pubDate>
		<dc:creator>Scottk</dc:creator>
	</item><item>
		<title>By: socratic</title>
		<link>http://ask.metafilter.com/15093/Php-session-help-requested#259450</link>	
		<description>Hm.  If you echo $_COOKIE[&apos;PHPSESSID&apos;] do you get a value?  &lt;br&gt;
&lt;br&gt;
What about echoing session_save_path()?  Does the path to save session data exist?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.15093-259450</guid>
		<pubDate>Sun, 13 Feb 2005 16:56:51 -0800</pubDate>
		<dc:creator>socratic</dc:creator>
	</item><item>
		<title>By: socratic</title>
		<link>http://ask.metafilter.com/15093/Php-session-help-requested#259451</link>	
		<description>(that first question, about PHPSESSID, may be a wild goose chase, as the PHP session cookie may be called something else, but I believe PHPSESSID is the default.)</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.15093-259451</guid>
		<pubDate>Sun, 13 Feb 2005 17:00:26 -0800</pubDate>
		<dc:creator>socratic</dc:creator>
	</item><item>
		<title>By: revgeorge</title>
		<link>http://ask.metafilter.com/15093/Php-session-help-requested#259552</link>	
		<description>If you are doing any redirections or calling exit() that can cause the session not to get saved.  You can get around this by calling &lt;a href=&quot;http://php.net/session_write_close&quot;&gt;session_write_close&lt;/a&gt;.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.15093-259552</guid>
		<pubDate>Sun, 13 Feb 2005 20:01:15 -0800</pubDate>
		<dc:creator>revgeorge</dc:creator>
	</item><item>
		<title>By: delfuego</title>
		<link>http://ask.metafilter.com/15093/Php-session-help-requested#259554</link>	
		<description>(You didn&apos;t mention what minor version of PHP you&apos;re running; before 4.1, $_SESSION wasn&apos;t an superglobal variable, prior to 4.0.6 $_SESSION didn&apos;t exist but was instead $HTTP_SESSION_VARS, and before 4.0.3, there was a variable, &lt;em&gt;track_vars&lt;/em&gt;, that needed to be set to true for the session-related variables to even make it into the $HTTP_SESSION_VARS array.  Which version is it you&apos;re running?)&lt;br&gt;
&lt;br&gt;
In any event:&lt;br&gt;
&lt;ol&gt;&lt;br&gt;
&lt;li&gt;Find a page that you&apos;ve discovered doesn&apos;t have access to the session variables.  (You say that it&apos;s pretty much every page, so this shouldn&apos;t be hard.)&lt;/li&gt;&lt;br&gt;
&lt;li&gt;Insert the following block of code at the very top of the page:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;&amp;lt;?php&lt;br&gt;
session_start();&lt;br&gt;
print_r($_COOKIE);&lt;br&gt;
print_r($_SESSION);&lt;br&gt;
echo session_id();&lt;br&gt;
?&amp;gt;&lt;/code&gt;&lt;/li&gt;&lt;br&gt;
&lt;li&gt;Change one of your other pages -- one that both sets a session variable &lt;em&gt;and&lt;/em&gt; includes a form -- so that the form&apos;s action points to the page that you modified in step 2 above.&lt;/li&gt;&lt;br&gt;
Visit the page from step 3 in your browser, submit the form, and then tell us what the resultant page shows.&lt;br&gt;
&lt;/ol&gt;&lt;br&gt;
(Of course, if you&apos;re on a version prior to 4.0.6, substitute in the appropriate variables for $_COOKIE and $_SESSION...)</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.15093-259554</guid>
		<pubDate>Sun, 13 Feb 2005 20:05:56 -0800</pubDate>
		<dc:creator>delfuego</dc:creator>
	</item>
	</channel>
</rss>
