session start problems?

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
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

session start problems?

Post by psychotomus »

i had this script working a few months ago, then read about some php5 upgrades (not sure if added on my server) but could be the problem since i never took the time to see if anything changed in php5 yet.

code line 1 2 3
<?php
session_start();
?>
then some html
then some more <?php

?>
but problems are on session_start();

Warning: session_start(): open(C:\PHP\sessiondata\sess_f449f5ddd4eb8c78ecf1ad68f387d10a, O_RDWR) failed: Permission denied (13) in C:\webspace\aspweb\po2admin\po2.net\www\update.php on line 2

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at C:\webspace\aspweb\po2admin\po2.net\www\update.php:2) in C:\webspace\aspweb\po2admin\po2.net\www\update.php on line 2

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at C:\webspace\aspweb\po2admin\po2.net\www\update.php:2) in
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Post by JPlush76 »

have you tried using
ob_start();

right above that session_start() line?
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Not a headers issue by the look to me, as it sais permission denied. The permission denied msg then creates the headers sendt msg...

Is the server IIS? If so, verify that php/server has write permission in that dir.
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

For php sessions to work, php must be able to access the folder where sessions are saved. If the current folder has an owner/group different to the php uid, create a folder with mkdir($path, 0755); and use that. Since php created the folder, it will have the php owner/group.

A phpinfo(); will show you the current session save path - edit in php.ini.

Setting a folder to 777 makes it accessible to anything regardless of uid - and that's exactly why you don't want to leave it set to 777, except possibly for a quick test to confirm what's going on.

You can read owner/groups (and modes) for files & folders by connecting with an ftp program and doing a dirinfo or similar.

The header error occurs because an error message has been output to the browser before the session (header) call.
Post Reply