use of session...

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
llharper
Forum Newbie
Posts: 3
Joined: Wed Feb 13, 2008 7:50 pm

use of session...

Post by llharper »

I did a quick search and did not find this topic. Sorry if this is old, it's new for me...

First, I am very new to PHP and Linux. In fact....
I got my first Linux box today. I installed Debain, Apache-SSL (1.3.34.BEN-SSL/1.55), and PHP 5. MySQL will come later. All configurations are the default settings. No changes have been made to Apache or PHP5.

I have been working on a large project, so far about 30 php files. All of these are working on a Windows XP, Apache2, PHP5 and MySQL system. The problem is the the same code does not work on the Debian system. It all has to do with Sessions. The following code shows my problem:
<?php
session_start();
$_SESSION["myname"] = "Larry";
echo "[".$_SESSION["myname"]."]";
session_write_close();
?>

On the Windows system this returns: [Larry]
On the Debian system this returns: []

Can someone please tell me what I'm doing wrong?
Could it be the Apache-SSL?
Or even the rights in the var/www directory?

Thanks for the help,
Larry
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: use of session...

Post by Christopher »

It sounds likes sessions are not working. Check that the directory specified for session files in php.ini exists and is writable by the Apache process.
(#10850)
llharper
Forum Newbie
Posts: 3
Joined: Wed Feb 13, 2008 7:50 pm

Re: use of session...

Post by llharper »

After doing a little looking around I can say that there appears to be a session file in the var/lib/php5 directory. Actually there are several files in the directory. It looks like a new one is created each time I stop Win Explorer and reload the php script. Which is sort of what I'd expect. However, when I open each file using Nano it seems to be empty.

Larry
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: use of session...

Post by califdon »

llharper wrote:After doing a little looking around I can say that there appears to be a session file in the var/lib/php5 directory. Actually there are several files in the directory. It looks like a new one is created each time I stop Win Explorer and reload the php script. Which is sort of what I'd expect. However, when I open each file using Nano it seems to be empty.

Larry
Read arborint's instruction more closely. Never mind what files are in the directory. Examine the php.ini file, it contains all the configuration settings for PHP. Most likely it specifies the wrong directory path for the session files.
llharper
Forum Newbie
Posts: 3
Joined: Wed Feb 13, 2008 7:50 pm

Re: use of session...

Post by llharper »

Sorry, I didn't include the first thing I did...
I edited the php.ini file to use the /var/lib/php5 directory. At the same time I edited the php.ini file on the Windows system to use the C:\tmp directory. In the Debian system I used the File Browser to locate the PHP5 directory and path to it. Remember this is the first time I've used Linux, so I don't know where things are..... Using the File Browser it indicates that I can not view the PHP5 directory contents. The owner appears to be 'root.' So, I used the Debian Terminal Application to change to the - I guess it would be the 'root user' using the "su -" command. Then, using the Terminal Application, I selected the proper directory (/var/lib/php5) and used the Nano editor to view the file contents. I did the same basic thing in the Windows system and the file contained the following:

myname|s:5:"Larry';

The session files in the Debain system are empty. A new file is created every time I stop and restart IE and run the test.php file. This is the same on both operating systems.

I must admit that I am assuming that if a new file is created then PHP has the rights to create the file and modify the file. So, why is it not working?

Again, Thanks for the help,
Larry
Post Reply