/    Sign up×
Community /Pin to ProfileBookmark

session error

I’m trying to use an old script I made. But for some reason it worked before and gives me errors today. What do these errors mean?

[code=php]
Warning: session_start() [function.session-start]: open(/public/tmp/sess_ea2351a0fe991d4f0a896f479105b8d6, O_RDWR) failed: No such file or directory (2) in /public/sites/www.kunstopdekoffie.nl/cms/img/imageManager.php on line 3

Warning: session_start() [function.session-start]: Cannot send session cookie – headers already sent by (output started at /public/sites/www.kunstopdekoffie.nl/cms/img/imageManager.php:3) in /public/sites/www.kunstopdekoffie.nl/cms/img/imageManager.php on line 3

Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /public/sites/www.kunstopdekoffie.nl/cms/img/imageManager.php:3) in /public/sites/www.kunstopdekoffie.nl/cms/img/imageManager.php on line 3

Warning: set_time_limit() [function.set-time-limit]: Cannot set time limit in safe mode in /public/sites/www.kunstopdekoffie.nl/cms/img/imageManager.php on line 10

Warning: Unknown: open(/public/tmp/sess_ea2351a0fe991d4f0a896f479105b8d6, 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 (/public/tmp) in Unknown on line 0[/code]

This is the first part of the script I use:

[code=php]<?php
require_once(‘../pages/database.php’);
require_once(‘../pages/config.php’);

//|||||||||||Start Session to remember table and id ||||||
session_start();
header(“Cache-control: private”); //IE 6 Fix
if ($destroy){
$_SESSION[‘tableName’] = $_GET[‘tableName’];
$_SESSION[‘id’] = $_GET[‘id’];
}
//set time limit off
set_time_limit(0);
[/code]

Hope someone can help me with this.
Thanks zeb

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@No_Effin_WayNov 23.2010 — Not sure whats in config or database but you should put Start_session() right after <?php
Copy linkTweet thisAlerts:
@NogDogNov 23.2010 — You need to address the first error:

Warning: session_start() [function.session-start]: open(/public/tmp/sess_ea2351a0fe991d4f0a896f479105b8d6, O_RDWR) failed: No such file or directory (2) in /public/sites/www.kunstopdekoffie.nl/cms/img/imageManager.php on line 3
[/quote]

Either your php.ini settings need to be changed to have [url=http://www.php.net/manual/en/session.configuration.php#ini.session.save-path]session.save_path[/url] point to the correct directory, or have the system administrator make sure that the specified directory exists and is writable by the user under which PHP is run (usually the Apache user).

Alternatively, you can create your own session data directory, and assign it at the script level via [url=http://www.php.net/manual/en/function.session-save-path.php]session_save_path[/url](), but if you do that, you need to be sure to do it [i]before[/i] calling session_start() on every affected script.
Copy linkTweet thisAlerts:
@eval_BadCode_Nov 23.2010 — NogDog is correct about the 1st error.

The second error has to do with line 3:

require_once('../pages/config.php');

Some type of output is occurring here, your sessions need to start before any output is sent. It can even be something as simple as a line break in your code that occurs after the closing php tag "?>" in config.php. It doesn't display in html, but it's source code that may be sent depending on how you're editor's method of handling new lines. You might also have tried to start a session with the same default session name (I'm saying config.php might already have session_start(); in it).
Copy linkTweet thisAlerts:
@aj_nscNov 23.2010 — The only reason the common "output already started" warning is shown is because other warnings were generated (and outputted to the browser) before the session could be started. Solve the first error that NogDog pointed out, and it appears you'll solve them all.

EDIT: The fourth warning generated shows your host is running php in safe mode - a feature deprecated in PHP 5.3 (so, obviously their php is not up to date) - and, thus, highly discouraged.

Try adding this line to the top of your script (before your require):

[code=php]
session_save_path('/path/to/tmp/directory')
[/code]


So if your root directory is /home/user_name/www/www/

Create a directory above your root, such as /home/user_name/www/sessions

and then use:
[code=php]
session_save_path('/home/user_name/www/sessions')
[/code]


Also, contact your host with this error and tell them that PHP has deprecated the use of safe mode and you'd appreciate it if they'd stay up to date and turn it off on their systems as well.
Copy linkTweet thisAlerts:
@zebdaagauthorNov 24.2010 — got it fixed.

I created a new folder called tmp.

And turned the "safe Mode" off.
×

Success!

Help @zebdaag spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...