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
use of session...
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: use of session...
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)
Re: use of session...
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
Larry
Re: use of session...
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 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
Re: use of session...
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
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