Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I fix the Permission error when I call session_start()?

Tags:

when I uploaded the script to the server I got this error

Warning: Unknown: open(/tmp/sess_58f54ee6a828f04116c2ed97664497b2, O_RDWR) failed: Permission denied (13) 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 

The error appeared when I call session_start(), although I set the permission of /tmp folder to 777.

like image 700
Waseem Senjer Avatar asked Jan 03 '11 14:01

Waseem Senjer


People also ask

What is session_start () function?

session_start() creates a session or resumes the current one based on a session identifier passed via a GET or POST request, or passed via a cookie. When session_start() is called or when a session auto starts, PHP will call the open and read session save handlers.

Where should the session_start () function be used?

Note: The session_start() function must be the very first thing in your document. Before any HTML tags. As for your question you can start session wherever you want, but beware that session must be started before any output.

Do I need to call session_start on every page?

It must be on every page you intend to use. The variables contained in the session—such as username and favorite color—are set with $_SESSION, a global variable. In this example, the session_start function is positioned after a non-printing comment but before any HTML.

How do you activate session in PHP?

Start a PHP Session A session is started with the session_start() function. Session variables are set with the PHP global variable: $_SESSION.


2 Answers

Change session path where you can write data or contact server administrator about /tmp problem

http://php.net/manual/en/function.session-save-path.php

like image 146
Tadas Šubonis Avatar answered Oct 02 '22 20:10

Tadas Šubonis


you will need to change your session.save_path php.ini directive

You can do that using session_save_path

like image 36
German Rumm Avatar answered Oct 02 '22 21:10

German Rumm