# Multiple storage folders

**URL:** <https://discourse.getcockpit.com/t/multiple-storage-folders/236>\
**Category:** General\
**Created:** [September 1, 2018, 10:18pm UTC](https://discourse.getcockpit.com/t/multiple-storage-folders/236 "2018-09-01T22:18:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Serpico](https://avatars.discourse-cdn.com/v4/letter/s/7feea3/32.png) [@Serpico](https://discourse.getcockpit.com/u/Serpico)\
**Post date:** [September 1, 2018, 10:18pm UTC](https://discourse.getcockpit.com/t/multiple-storage-folders/236/1 "2018-09-01T22:18:51Z")

</div>

Hi,

I’d love to know if there’s a way to somehow specify the storage folder to be used on a per request basis.

My goal is to enable multiple site contents to be managed with a single Cockpit installation. Ideally, depending on the URL used to get to cockpit, I’d like to point to a different storage dir.

---

<div class="post-metadata">

**Author:** ![serjoscha87](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/serjoscha87/32/151_2.png) [@serjoscha87](https://discourse.getcockpit.com/u/serjoscha87)\
**Post date:** [September 2, 2018, 8:02am UTC](https://discourse.getcockpit.com/t/multiple-storage-folders/236/2 "2018-09-02T08:02:48Z")

</div>

I once had the exact same intention and also tried hard to implement a chance of having multiple storage dirs.

Lately after (unsuccessfully) trying around I came up with another approach that results in the exact same result:

> **[serjoscha87/cockpit\_GroupBoundAssets](https://github.com/serjoscha87/cockpit_GroupBoundAssets)**
>
> Addon for https://github.com/agentejo/cockpit. Contribute to serjoscha87/cockpit\_GroupBoundAssets development by creating an account on GitHub.

Install this and create groups for every customer within the one cockpit installation.

This addons makes all users only see assets uploaded by their own group.

The result is completely the same as you desire it - but there will still be just one storage dir.

---

<div class="post-metadata">

**Author:** ![artur](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/artur/32/4_2.png) [@artur](https://discourse.getcockpit.com/u/artur)\
**Post date:** [September 2, 2018, 10:34am UTC](https://discourse.getcockpit.com/t/multiple-storage-folders/236/3 "2018-09-02T10:34:11Z")

</div>

One option can be to create a file named `defines.php` in the cockpit root folder.

This file will always be auto-loaded before cockpits initialization.

In that file you can set the constant `COCKPIT_STORAGE_FOLDER` based on `$_SERVER['SERVER_NAME']`

FYI:

> <https://github.com/agentejo/cockpit/blob/next/bootstrap.php#L28-L30>

  

> <https://github.com/agentejo/cockpit/blob/next/bootstrap.php#L59>

Greets  
Artur

---

<div class="post-metadata">

**Author:** ![Serpico](https://avatars.discourse-cdn.com/v4/letter/s/7feea3/32.png) [@Serpico](https://discourse.getcockpit.com/u/Serpico)\
**Post date:** [September 2, 2018, 4:55pm UTC](https://discourse.getcockpit.com/t/multiple-storage-folders/236/4 "2018-09-02T16:55:04Z")

</div>

Thank you both for your input. Right now I’m experimenting with COCKPIT\_STORAGE\_FOLDER in defines.php , and looks promising.

One thing I had to do though that’s worth noting is changing the value of the session.name config, otherwise logged users could use their own session to access another storage.

I just hope that having many concurrent users accessing different storage directories doesn’t cause any problems due to the amount of open files, that’s something I’ll need to test.

---

<div class="post-metadata">

**Author:** ![easysoft-mobility](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/easysoft-mobility/32/500_2.png) [@easysoft-mobility](https://discourse.getcockpit.com/u/easysoft-mobility)\
**Post date:** [February 17, 2020, 2:23pm UTC](https://discourse.getcockpit.com/t/multiple-storage-folders/236/5 "2020-02-17T14:23:21Z")

</div>

> [@Serpico](#):
>
> defines.php

Hello !  
Please, can we have a concret example of the defines.php thing ?  
I realy need storage folder based on user but don’t know how to implement that.
