Bobcares

Best way to fix – PHP Warning session.save_path not set

by | Oct 24, 2019

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

That was an error message our customer recently got while accessing his website.

Usually, this error occurs due to improper settings of the PHP directive session.save_path.

At Bobcares, we often get requests to fix PHP session errors as a part of our Server Management Services.

Today, let’s have a look into the error and see how our Support Engineers fix it.

 

What is PHP Warning session.save_path not set error?

The main function of a PHP session file is to make data accessible across the various pages of an entire website.

It’s a simple way to store data for individual users.

If we receive the error means, there is a problem with session.save_path configuration and sessions will not work.

Recently one of our customers contacted us with this PHP Warning session.save_path not set error while accessing his website contents.

The typical error was like this:

The error indicated that the session.save_path not configured correctly.

 

How to find the PHP Warning session.save_path not set on the server?

To find out the session.save path value set on the server, we do the following steps.

1. First, we login to the server.

2. Then we test if session.save_path is set on the server. For that, we create a file with any text editor and name it with phpinfo.php.

example:    vi phpinfo.php   (add below code to this file)

<?php
phpinfo();
?>

Then we save the file phpinfo.php.

3. Then we upload this file to the customer’s site and then access this in web browsers using the link http://yourwebsite.com/phpinfo.php

4. After that, we look for the entry that says: session.save_path  like below.

In the value of the directive, session.save_path is no value, it means session.save_path is not configured and sessions will not work.

So we need to update the session save path in the php.ini file.

 

How we fix PHP Warning session.save_path not set error?

So far, we discussed the php session error. Now, let’s see how our Support Engineers fix this error for our customers.

The session.save_path is a PHP directive that needs to be set in PHP configuration settings (the php.ini file).

To fix the error, we do the following steps.

1. We login to the server.

2. Then we check for the PHP Handler in use. For instance, in cPanel servers, we use

/usr/local/cpanel/bin/rebuild_phpconf --current

3. We get the output as below.

Available handlers: dso cgi none
DEFAULT PHP: 5
PHP4 SAPI: none
PHP5 SAPI: dso
SUEXEC: enabled

Enabling the session save path depends on the type of the PHP handler. Let’s take a look at the exact steps on DSO and SuPHP.

Case 1: PHP handler – DSO  (using .htaccess file)

1. If the handler is dso then we move on to the document root of the user.

2. Then we create a temporary directory called /tmp with 777 permission in the website folder.

Example :

[#root@server#:cd /home/username/public_html]
(root)> ll |grep tmp
drwxrwxrwx 2 p9r11734 p9r11734 23552 Oct 12 09:08 tmp
[#root@server#/home/username/public_html]

3. After that, we open the .htaccess file and add the following lines to it.

php_value session.save_path /home/username/public_html/tmp

4. We Save and quit the file.

5. Then we check this using a PHP info page and search for session.save_path. If it shows /home/username/public_html/tmp, then we make sure that we have set the correct path.

 

Case 2: PHP handler – suphp   (using php.ini file)

Similarly, if the PHP handler is suphp, then we do the following steps.

1. We create a custom php.ini file inside the website.

vi /etc/php.ini

2. And add the entry for  session.save_path to /home/username/public_html/tmp  in this php.ini file.

3. Then we save and quit the file.

This fixes the PHP Warning session.save_path not set error for our customers.

 

[Need more assistance in PHP Warning session.save_path not set error? We’ll fix it for you.]

 

Conclusion

In short, the php session error occurs due to no value set in the directive session.save_path or session.save_path not configured. Today, we saw how our Support Engineers fix this error for our customers.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

2 Comments

  1. Juan Carlos Aldazosa

    Very detailed tutorial, solved some problems thanks to this post.

    Reply
    • Hiba Razak

      Hi Juan ,
      Thanks for the feedback. We are glad to know that our article was helpful for you 🙂 .

      Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF