easy problem...

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
nshah
Forum Newbie
Posts: 5
Joined: Wed Apr 14, 2004 11:08 pm

easy problem...

Post by nshah »

this is just a basic code i got off of a site to see how sessions work in php
unfortunately... i got warnings and errors right off the bat...
can someone help fix these errors?

the code for page1.php

[b]<?php
// page1.php

session_start();

echo 'Welcome to page #1';

$_SESSION['favcolor'] = 'green';
$_SESSION['animal'] = 'cat';
$_SESSION['time'] = time();

// Works if session cookie was accepted
echo '<br /><a href="page2.php">page 2</a>';

// Or maybe pass along the session id, if needed
echo '<br /><a href="page2.php?' . SID . '">page 2</a>';
?>[/b]


--the following are the warnings i get when executing the above code


[b]Warning[/b]: session_start(): open(/tmp\sess_f743e31918e568464636b50f8b3fbeb8, O_RDWR) failed: No such file or directory (2) in c:\web\page1.php on line 4

[b]Warning[/b]: session_start(): Cannot send session cookie - headers already sent by (output started at c:\web\page1.php:4) in c:\web\page1.php on line 4

[b]Warning[/b]: session_start(): Cannot send session cache limiter - headers already sent (output started at c:\web\page1.php:4) in c:\web\page1.php on line 4
Welcome to page #1
page 2
page 2
[b]Warning[/b]: Unknown(): open(/tmp\sess_f743e31918e568464636b50f8b3fbeb8, O_RDWR) failed: No such file or directory (2) in Unknown on line 0

[b]Warning[/b]: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0


its really frustrating :cry:
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Edit c:\windows\php.ini and change session.save_path from /tmp to :

session.save_path c:\temp
(or some other temporary directory that exists)
Then restart apache (if you're using it).
nshah
Forum Newbie
Posts: 5
Joined: Wed Apr 14, 2004 11:08 pm

Post by nshah »

well these are the three different ways i tried changing that line in php.ini

session.save_path = "c:\temp"

session.save_path = c:\temp

session.save_path c:\temp

and i restarted apache after trying each one of these

i still came up with these errors

Warning: session_start(): open(/tmp\sess_39cae55f57f184575762f74202c18b2e, O_RDWR) failed: No such file or directory (2) in c:\web\page1.php on line 4

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at c:\web\page1.php:4) in c:\web\page1.php on line 4

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at c:\web\page1.php:4) in c:\web\page1.php on line 4
Welcome to page #1
page 2
page 2
Warning: Unknown(): open(/tmp\sess_39cae55f57f184575762f74202c18b2e, O_RDWR) failed: No such file or directory (2) in Unknown on line 0

Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Sounds like you might be editing the wrong php.ini file.
Create a <?php phpinfo() ?> page and that will show you which php.ini to edit.
nshah
Forum Newbie
Posts: 5
Joined: Wed Apr 14, 2004 11:08 pm

Post by nshah »

well i see the phpinfo() on my info.php page.... but i dont know where to look to see whether im editting the rite php.ini file....
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Right near the top of the phpinfo page there's a line that starts with :
Configuration File (php.ini) Path
What does it say to the right of that?
nshah
Forum Newbie
Posts: 5
Joined: Wed Apr 14, 2004 11:08 pm

yay

Post by nshah »

woah.... yeh i was editting the wrong file.... i found the rite file... and i got it to work.... thanks so much

Neil :D
Post Reply