Unique site slug/identifier


Is it possible to get a unique site slug? Like the domain?

Something like site()->slug()

Appreciate the help!

The site doesn’t have a slug, what do you mean?

I’m adding some cookies with localStorage, want to add a unique prefix before the cookie name.

So far I got this:

localStorage.getItem('<?= Str::slug(site()->title()) ?>-appearance')

That will use the site title as a safe version string.

Wondering if it’s possible to get this line a little cleaner? In short, trying to find a unique site identifier that is global.

The site object doesn’t have an identifier. Maybe use the homepageid instead (will return home in most cases)?

For now I will use <?= Str::slug(site()->title()) ?> as it’s the most unique prefix I’ve found. Reason is the cookies are used among multiple sites. Just in case for them not to be “cross contaminated” :sweat_smile:

Thanks for your help!