I am using PHP 5 and I ran into a problem using $_SESSION and session_start() because they do not store values. I have the register_globals option set to Off and the session.auto_start set to 0. I am running apache 2.0 on my computer (Windows XP) as a test server through localhost.

The save path for session in my ini file is: ;session.save_path = "C:\Temp"

I added a simple example to show the problem. Maybe someone has useful information on how to solve it. (it has also caused me trouble when I am trying to use User Authentication Applications).

If some one owns the book PHP and MySQL web development by Laura Thompson and Luke Welling, my trouble resides on chapters 22, 26 and 28 when trying to log into the CMS.

Example:

page1.php-------------------------------------------------------

<?php
// This first page is suppoused to store "Hello world!" as a value in the $_SESSION['sess_var'] so it can pass it to page2.php


session_start();

$_SESSION['sess_var'] = "Hello world!";

echo 'The content of $_SESSION[\'sess_var\'] is '
.$_SESSION['sess_var'].'<br />';
?>
<a href="page2.php">Next page</a>

page2.php-------------------------------------------------------

<?php
// Somehow it does not display "Hello World!"

session_start();

echo 'The content of $_SESSION[\'sess_var\'] is '
.$_SESSION['sess_var'].'<br />';

unset($_SESSION['sess_var']);
?>
<a href="page3.php">Next page</a>

BROWSER OUTPUT:

I would expect page1.php and page2.php to show:

The content of $_SESSION is Hello world!
Next page

But page2.php only shows:

The content of $_SESSION is (IT DOES NOT PASS THE VALUE)
Next page


Thank You :o

Change the line in php.ini to this:

session.save_path = c:/Temp/

BTW, that semicolon is commenting out your line, it will not be effective if you leave it. Also, forward slashes are required as is trailing slash and lowercase drive letter. Don't ask me why, I discovered it by trial and error.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.