Session save_path php ini

Get full access to Advanced PHP for Web Professionals and 60K+ other titles, with free 10-day trial of O'Reilly.

There's also live online events, interactive content, certification prep materials, and more.

If you're not satisfied with MyDomain, we'll give you your money back. No questions asked. During the first 30 days, we'll refund your hosting fees in full.

Customer Satisfaction at MyDomain

Your satisfaction is our top priority, and we're confident that you'll be pleased with our services:

  • how easy it is to set up a website
  • friendly, 24x7 phone support
  • SiteLock's state-of-the-art security suite

Still, if you try us and decide that MyDomain just isn't for you, we think you should get your money back.

What Happens to Your Domain

If you register a domain through MyDomain, please note there is a non-refundable $15 domain fee. This fee not only covers our own costs, but it ensures that, even if you're dissatisfied with your experience at MyDomain, you won't lose your domain name. You'll be free to transfer it or simply point it elsewhere.

Please note: The 30-day money-back guarantee applies to our hosting plans; it does not apply to most add-on services, such as domains, as mentioned above.

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)

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.

How to set session save_path in PHP?

Create a folder named session in the C:\session. Change the session. save_path(); directory to the newly created path: ( C:\session ) anywhere out of tmp folder. Save this answer.

What is the default session save_path in PHP?

By default, PHP stores session data in files and files are stored in the /tmp directory of your server. Each session is stored in its own file. echo session_save_path(); session data file stored in /tmp is like sess_1f1b1bdb809709f09f45b049998f25dc43745a67.

Where is PHP session storage?

PHP Session Start By default, session data is stored in the server's /tmp directory in files that are named sess_ followed by a unique alphanumeric string (the session identifier). By itself, the session_start() function doesn't add much functionality to a web page.

How to set unlimited session timeout in PHP?

The timeout limit of the session can be set by setting the value of two directives in the php. ini file or using the ini_set() function in the PHP script. The directives are given below. It is used to set the time limit in seconds to store the session information in the server for a long time.