benn600 Posted November 14, 2007 Share Posted November 14, 2007 I cannot get sessions working on my PHP install. It's Apache with PHP. If I create the two files as shown here: http://www.php.net/manual/en/function.session-start.php Nothing shows up on page2 as I think it should. I am making a small site, also, where I want to use sessions and they do not appear to be working. What may be wrong? Link to comment https://forums.phpfreaks.com/topic/77260-solved-problem-getting-sessions-working/ Share on other sites More sharing options...
pocobueno1388 Posted November 14, 2007 Share Posted November 14, 2007 Look at your php info <?php phpinfo(); ?> Go down and find where it says "Session Support" and see if it says "enabled". Link to comment https://forums.phpfreaks.com/topic/77260-solved-problem-getting-sessions-working/#findComment-391150 Share on other sites More sharing options...
benn600 Posted November 14, 2007 Author Share Posted November 14, 2007 Absolutely, sessions are enabled. session Session Support enabled Registered save handlers files user Registered serializer handlers php php_binary wddx Here are the two pages (directly copied from above link) http://ppcpathways.com/page1.php http://ppcpathways.com/page2.php <?php // page1.php session_start(); echo 'Welcome to page #1'; $_SESSION['favcolor'] = 'green'; $_SESSION['animal'] = 'cat'; $_SESSION['time'] = time(); // Works if session cookie was accepted echo '<br /><a href="page2.php">page 2</a>'; // Or maybe pass along the session id, if needed echo '<br /><a href="page2.php?' . SID . '">page 2</a>'; print '<br /><br />AND here is PHP info'; phpInfo(); ?> <?php // page2.php session_start(); echo 'Welcome to page #2<br />'; echo $_SESSION['favcolor']; // green echo $_SESSION['animal']; // cat echo date('Y m d H:i:s', $_SESSION['time']); // You may want to use SID here, like we did in page1.php echo '<br /><a href="page1.php">page 1</a>'; ?> Link to comment https://forums.phpfreaks.com/topic/77260-solved-problem-getting-sessions-working/#findComment-391151 Share on other sites More sharing options...
Northern Flame Posted November 14, 2007 Share Posted November 14, 2007 what version of PHP are you using? Link to comment https://forums.phpfreaks.com/topic/77260-solved-problem-getting-sessions-working/#findComment-391155 Share on other sites More sharing options...
benn600 Posted November 14, 2007 Author Share Posted November 14, 2007 PHP Version 5.2.4 The first file shows you my PHPInfo and above (in quotes) I have the source to these two files. http://ppcpathways.com/page1.php http://ppcpathways.com/page2.php Link to comment https://forums.phpfreaks.com/topic/77260-solved-problem-getting-sessions-working/#findComment-391156 Share on other sites More sharing options...
Northern Flame Posted November 14, 2007 Share Posted November 14, 2007 try making a new script, try this: page1.php <?php session_start(); $_SESSION['test'] = 'It Worked!'; echo '<a href="page2.php">page2</a>'; ?> page2.php <?php session_start(); if(!isset($_SESSION['test'])){ echo 'It\'s not working....'; } else{ echo $_SESSION['test']; } ?> that should work, if it doesnt, that i really have no idea whats wrong.... Link to comment https://forums.phpfreaks.com/topic/77260-solved-problem-getting-sessions-working/#findComment-391170 Share on other sites More sharing options...
benn600 Posted November 14, 2007 Author Share Posted November 14, 2007 Thanks for your help. I decided to reinstall. I installed the latest but got an error code. So I tried the one I had before, and again got an error! So I downloaded the zip. Then I unzipped it and installed. Sessions started working but MySQL didn't. I compared my previous and new php.ini files and found the problem. It turns out changing allow_call_time_pass_reference fixed it for me. ALL GOOD NOW! I'm building a Christmas Wish List application for my family. Should be interesting. Thanks! Link to comment https://forums.phpfreaks.com/topic/77260-solved-problem-getting-sessions-working/#findComment-391185 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.