less than a minute read • Updated 8 minutes ago
Configure the session domain and cookie path
How to reset a Foxy session, and control which domain and path the session cookie is set on when isolating sessions by subdomain or section.
Foxy sets a session cookie (fcsid) to track each visitor’s cart across pages. Most stores never need to touch this, but if your site uses multiple subdomains or sections that each need their own isolated session, you can control where and how that cookie is set — or clear a session out entirely.
Reset a session
To completely clear out a Foxy session:
FC.session.reset();
Set the session domain
sitedomain controls which domain the fcsid cookie is set on. By default, if your domain is passed in as example.com or www.example.com, the cookie is set at the second-level domain — .example.com. For a third-level domain like subdomain.example.com, the cookie is set at .subdomain.example.com.
Set it inside FC.onLoad:
var FC = {
onLoad: function () {
FC.settings.sitedomain = 'store1.example.com';
}
}
This matters if your site isn’t at the second-level domain, or if you want to isolate sessions by subdomain — for example, if you run separate Foxy stores at donations.example.com and products.example.com and don’t want their sessions to overlap, or if your site is hosted at a third-party domain like example.squarespace.com and you don’t want your session shared across every site on that domain.
Notes
The
wwwsubdomain is effectively ignored when counting domain levels. To lock sessions down towww.example.comspecifically, setsitedomainto something likewww1.example.com— the actual value doesn’t matter, only the number of dots afterwwwis stripped.If you isolate sessions by subdomain, Foxy’s JavaScript can’t also be loaded at a parent domain. For example, with separate stores at
products.example.comanddonations.example.com, you can’t also load Foxy atwww.example.comorexample.com— that would set the session cookie at.example.comand override both subdomain sessions.cookiepathmust start and end with a/, or you may run into issues (especially in older browsers).If splitting sessions by path, the trailing slash is critical —
example.com/bookstore/andexample.com/donations/work, butexample.com/bookstoreandexample.com/donations(without trailing slashes) will collide.sitedomainandcookiepathare set onFC.settingsinsideFC.onLoad, not withFC.override— see Configure JavaScript loading options for the override pattern used elsewhere.