<p><strong>This is completely inaccurate, please disregard!</strong> I’ll work with Chad to come up with something useful, or delete it outright.</p>
<hr />
<p>Multi-environment <a href="https://craftcms.com/docs/3.x/config/config-settings.html" rel="nofollow noreferrer">configuration</a> (3.x) uses site handles at the top level of the returned array.</p>
<p>Currently, Craft interprets this as having the following <code>defaultTokenDuration</code> for all sites…</p>
<pre class="lang-php prettyprint-override"><code>[
  '*' =&gt; 259200,
  'otherSite' =&gt; 1800,
]
</code></pre>
<p>…which isn't a valid &quot;duration&quot; format! </p>
<p>Instead, your config file should look something like this:</p>
<pre class="lang-php prettyprint-override"><code>return [
   '*' =&gt; [
        'defaultTokenDuration' =&gt; 259200,
    ],
    'otherSite' =&gt; [
        'defaultTokenDuration' =&gt; 1800,
    ],
];
</code></pre>
<p> <strong>Keep in mind:</strong> These tokens aren’t always generated in circumstances where the current &quot;site&quot; is known or defined—for example, an administrator sending a password reset email to a user, or a live preview request.</p>

CC BY-SA 4.0
2022-10-25T20:31:07.453Z
Thank you - but my config array at the top level is environment-specific, not site specific. Can you explain how I'd add the otherSite array to this? https://gist.github.com/chadcrowell/d5fce78742c0185fd3c32b509613aeba
Chad Crowell
CC BY-SA 4.0
2022-10-24T17:17:53.223Z
2022-10-26T20:31:02.197Z
2022-10-26T20:31:02.197Z
August Miller
<p>I currently have a multi-site Craft 3 install with this in the general.php config file (amongst other settings)</p>
<pre><code>return [
   '*' =&gt; [
       'defaultTokenDuration' =&gt; 259200, //72 hours
    ]
]
</code></pre>
<p>Which works fine for all sites allowing logged in users to remain logged in for 72 hours. I'm adding a new site where we need the duration to be 30 minutes.</p>
<p>I tried this:</p>
<pre><code>return [
   '*' =&gt; [
        'defaultTokenDuration' =&gt; [
            '*' =&gt; 259200, //72 hours
            'otherSite' =&gt; 1800 //30 minutes
        ]
    ]
]
</code></pre>
<p>where 'otherSite' is the handle of the new site. Craft is throwing this error:</p>
<p><code>yii\base\InvalidConfigException: Unable to convert to seconds. in /Users/chad/Repos/gcx-craft/vendor/craftcms/cms/src/helpers/ConfigHelper.php:49</code></p>
<p>I also tried replacing the * with the handle of the primary site and saw the same error, so I assume listing all sites with a value in that array is useless. Is there any way to specify different values for different sites for this setting?</p>

<users><session>
Multi-Site Craft 3 - How to set defaultTokenDuration to shorter duration for just 1 of the sites?
# Multi-Site Craft 3 - How to set defaultTokenDuration to shorter duration for just 1 of the sites?

(Asked by: username_0 on 2022-10-24)

I currently have a multi-site Craft 3 install with this in the general.php config file (amongst other settings)
return [
   '*' => [
       'defaultTokenDuration' => 259200, //72 hours
    ]
]

Which works fine for all sites allowing logged in users to remain logged in for 72 hours. I'm adding a new site where we need the duration to be 30 minutes.
I tried this:
return [
   '*' => [
        'defaultTokenDuration' => [
            '*' => 259200, //72 hours
            'otherSite' => 1800 //30 minutes
        ]
    ]
]

where 'otherSite' is the handle of the new site. Craft is throwing this error:
yii\base\InvalidConfigException: Unable to convert to seconds. in /Users/chad/Repos/gcx-craft/vendor/craftcms/cms/src/helpers/ConfigHelper.php:49
I also tried replacing the * with the handle of the primary site and saw the same error, so I assume listing all sites with a value in that array is useless. Is there any way to specify different values for different sites for this setting?

**Tags:** users, session


---

## 1 answers

### Answer by username_1 on 2022-10-24. Score: 0

This is completely inaccurate, please disregard! I’ll work with Chad to come up with something useful, or delete it outright.

Multi-environment configuration (3.x) uses site handles at the top level of the returned array.
Currently, Craft interprets this as having the following defaultTokenDuration for all sites…
[
  '*' => 259200,
  'otherSite' => 1800,
]

…which isn't a valid "duration" format! 
Instead, your config file should look something like this:
return [
   '*' => [
        'defaultTokenDuration' => 259200,
    ],
    'otherSite' => [
        'defaultTokenDuration' => 1800,
    ],
];

 Keep in mind: These tokens aren’t always generated in circumstances where the current "site" is known or defined—for example, an administrator sending a password reset email to a user, or a live preview request.

> **Comments:**
> **username_0**: Thank you - but my config array at the top level is environment-specific, not site specific. Can you explain how I'd add the otherSite array to this? https://gist.github.com/chadcrowell/d5fce78742c0185fd3c32b509613aeba  

---

