session_start() error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
victorsk
Forum Commoner
Posts: 43
Joined: Thu Apr 19, 2007 6:55 pm

session_start() error

Post by victorsk »

Hello,

I am trying to store object information in session in file1.php and then make file2.php get that session information. When I use session_start() call I get the following errors:

Code: Select all

Warning: session_start() [function.session-start]: open(/root/tmp/sess_f38d1b1f591c8126c53090d3ddea0f5a, O_RDWR) failed: Permission denied (13) in /var/www/html/test/doVacationsSearch_test.php on line 4

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /var/www/html/test/doVacationsSearch_test.php:4) in /var/www/html/test/doVacationsSearch_test.php on line 4

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /var/www/html/test/doVacationsSearch_test.php:4) in /var/www/html/test/doVacationsSearch_test.php on line 4
Could somebody please tell me what is going wrong here or how I can fix this?

Thank you,
Victor.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

php by default stores session data in files. The account running the php script does not have permissions to access these files.
The config parameter session.save_path sets the directory where these files are located, currently /root/tmp/
/root/tmp ?
victorsk
Forum Commoner
Posts: 43
Joined: Thu Apr 19, 2007 6:55 pm

Post by victorsk »

Hi,

Yes, I think I fixed by making everything executable (I think) in tmp with this command:

chmod -R +x /root/tmp

which I guess set everything to highest permissions possible. But I have other problems now on how to register an object in a session and have file2.php obtain that object.

Thanks,
Victor.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

chmod -R +x /root/tmp

which I guess set everything to highest permissions possible.
no, that would be +rwx to allow every- and anybody read/write/execute permissions.

Code: Select all

// file1
require 'class_foo.php';
session_start();

$_SESSION['obj'] = new foo;

Code: Select all

// file2
require 'class_foo.php';
session_start();

$_SESSION['obj']->bar();
victorsk
Forum Commoner
Posts: 43
Joined: Thu Apr 19, 2007 6:55 pm

Post by victorsk »

volka wrote:
chmod -R +x /root/tmp

which I guess set everything to highest permissions possible.
no, that would be +rwx to allow every- and anybody read/write/execute permissions.

Code: Select all

// file1
require 'class_foo.php';
session_start();

$_SESSION['obj'] = new foo;

Code: Select all

// file2
require 'class_foo.php';
session_start();

$_SESSION['obj']->bar();
Thank you so much for clarification. I have been doing this approach but every time I put require 'foo.php' (it's not a class just a PHP file that calls SOAP API methods) I get these methods being called when I launch file2.php but with parameters intended to be passed into file2.php, very strange. Does this mean that foo.php *must* be a class? I get the sense that if it is a class then foo.php's methods would be called only when invoked. But I'm new to PHP so I'd rather get some knowledgeable comments before I start converting foo.php into a standalone class.

Thank you,
Victor.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Sorry, I don't understand.
victorsk
Forum Commoner
Posts: 43
Joined: Thu Apr 19, 2007 6:55 pm

Post by victorsk »

Hi,

This problem has been transformed into a different thread, I hope you could help me with this please.

viewtopic.php?t=68153

Thank you,
Victor.
Post Reply