Jump to content

[SOLVED] Problem getting Sessions working


benn600

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.