Skip to main content
All CollectionsAdministering Server and WebsiteApplication Management
Setting up the Session Path from the Cloudways Platform
Setting up the Session Path from the Cloudways Platform

In this article, you will learn how to set the session path for your applications using the Cloudways Platform.

Usama Zafar avatar
Written by Usama Zafar
Updated over 3 months ago

Table of Contents

Cloudways offers highly customizable server-level PHP settings and PHP FPM settings that users can directly modify from the Cloudways Platform.

In this article, you will learn how to set the session path for your applications using the Cloudways Platform.

Important

If you use a custom session path and encounter errors while cloning your application or creating a staging application. In that case, we recommend updating the session path to /home/hostname/application_name/public_html/var/sessions, as this directory "var/sessions" is excluded by default from cloning and staging creation processes to avoid any conflicts.

Why You Should Set Up Session Path

Usually, a website is not intelligent enough to maintain any information about visitors navigating from one page to another. HTTP is a stateless protocol which means that a server can not remember every user among multiple requests, but you can easily handle this limitation by enabling the PHP sessions.

PHP sessions allow you to track each website visitor across different pages of a website and store information about them on a specific path, also known as the session save path. In addition, PHP sessions inform the server that all requests originate from the same visitor; thus, allowing you to customize the user experience and save their preferences.

How to Set the Session Path for an Application

Step #1 — Fetching the Server Hostname

You can set the Session Path from the Cloudways Platform, but you require a server hostname for it; therefore, connect to your server using SSH.

  1. Once you are connected, execute the following command to view the hostname and note it down.

hostname

Step #2 — Creating the Session Directory

Next, we need to create a directory to set that as a Session Path.

  1. Navigate to the public_html folder using the following command. Be sure to replace application_name with your application name. Your application name is also available on the Cloudways Platform.

cd applications/application_name/public_html/

2. Next, create a session directory using the following command.

mkdir session

Moreover, you can use the listing command to view the created directory.

ls

Step #3 — Setting the Session Path in PHP FPM Settings

Log in to your Cloudways Platform using your credentials.

  1. From the top menu bar, open Servers.

  2. Next, choose the server where your desired application is deployed.

    Classic Interface

    New Interface

  3. Click www (if you are using Classic Interface) or the globe icon (if you are using New Interface).

  4. Next, choose your application.

    Classic Interface

    New Interface

  5. Under Application Management, select Application Settings.

  6. Next, navigate to the PHP FPM Settings.

    Classic Interface

    New Interface

  7. Add the following PHP directive at the end. Make sure to replace hostname and application_name with the correct hostname and application name you noted earlier.

  8. Be sure to replace application_name with your application name. Your application name is also available on the Cloudways Platform. Do not add a semi-colon before the directive, as it will make it a comment.

    php_admin_value[session.save_path] = /home/hostname/application_name/public_html/session

    Finally, click Save Changes.

    Classic Interface

    New Interface

It should start saving the user-related sessions in your defined session path.

That’s it! We hope this article was helpful. If you need any help, then feel free to search your query on Cloudways Support Center or contact us via chat (Need a Hand > Send us a Message). Alternatively, you can also create a support ticket.


Stop Wasting Time on Servers
Cloudways handles server management for you so you can focus on creating great apps and keeping your clients happy. Start Free.

Did this answer your question?