We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22164
    • 50 Posts
    UPDATE: fixed here is how to get a cookieless subdomain...

    Open your modx index.php file and change the line where it says: $base_url = ’’; to $base_url = ’www.yourdomain.com’;

    beware that google analytics can still screw up things though, check http://modxcms.com/forums/index.php/topic,57012.0.html for the solution of that and the reason why I wanted a cookieless subdomain in the first place.


    -----------I leave original post intact so you can follow the line of thought--------------

    Does anybody know how to do this with modx?

    Wordpress seems to have a setting to limit the setting of cookies to www.domain.com in stead of domain.com
    it does that by adding the following line to wp-config.php
    define(’COOKIE_DOMAIN’, ’www.example.com’);

    In order to set up a cookieless subdomain I have to make sure that modx only sets cookies for www.example.com and not the top-level example.com. (Cookies set at the top-level domain apply to all subdomains as well.)

    Anybody know how to do this in modx?

    thanks

    Oliver
      Happy to have left Back Pain | Sciatica behind.
      • 22303 MODX Staff
      • 10,725 Posts
      You need to provide at least the basic information about what version of MODx you are using before anyone can help.
        • 22164
        • 50 Posts
        Hi OpenGeek

        I am proudly serving my sites with modx 1.0.4

        I also found this, maybe that helps:

        http://www.infotales.com/serving-images-from-cookie-less-domain/

        maybe a plugin is possible that limits the cookies to www.domain.com

        setcookie("TestCookie", $value, time()+3600, "/", "www.mydomain.com");

        tnx for the help

        Oliver
          Happy to have left Back Pain | Sciatica behind.
          • 22164
          • 50 Posts
          I think I found 3 options:

          Option 1
          In instprocessor.php on line 249 I found:

          setcookie(session_name(), session_id(), $cookieExpiration, MODX_BASE_URL);

          Is this what needs to change to limit the cookies to the www version of the domain only?

          Option 2
          Or should I change the $base_url in index.php to the www version of the domain? $base_url = ’www.domain.com’;

          Option 3
          Or should I add $base_url = ’www.domain.com’; to config.inc.php

          I tried 2 and removed the cookies from my browser but still am told to use cookieless domains for the subdomain.

          Help much appreciated.
            Happy to have left Back Pain | Sciatica behind.
            • 22303 MODX Staff
            • 10,725 Posts
            Cookieless domains? Do you mean you cannot set a PHP session cookie for the subdomain, or do you want separate cookies for the subdomain. There is no such thing as a cookieless subdomain in a MODx. There is always a session cookie.
              • 22164
              • 50 Posts
              I mean I want a subdomain in which I will not have anything setup at all, I only use it as a pointer to the place from where I serve my static files.

              For google site speed now is a factor to work on with regards to seo results. Seeing modx is great for seo reasons, and seeing I have lots of number 1 spots in google, but I want to stay ahead and therefore inquire about this.

              Google advises to serve images and css files from cookieless domains. Ofcourse I can set up a separate domain for this, but I would rather do it on a subdomain, if possible.

              I work with Amazon s3 and cloudfront to serve the files, and point a subdomain with cname in my dns to the amazons3 or cloudfront bucket. Cookies that are set for domain.com will also show up for www.domain.com and for any other subdomain for that matter.

              It would therefore be good to be able to contain the cookiesetting to the www version of the domain. Which php allows to do by setting the setcookie varible to www.domain.com (http://php.net/manual/en/function.setcookie.php)

              Now all I want is to be able to change this in modx so it works as I want it.

              I just added this to config.inc.php
              $cookiedomain= ’www.domain.com’;

              and further down change a line to: setcookie(session_name(), session_id(), $cookieExpiration, $cookiedomain);

              no luck yet though


              Thanks

              Oliver
                Happy to have left Back Pain | Sciatica behind.
                • 22164
                • 50 Posts
                If anyone need this:

                Just change $base_url in index.php to the www version of the domain? $base_url = ’www.domain.com’;

                and your cookies will be contained to the www section of your site.

                Good Luck
                  Happy to have left Back Pain | Sciatica behind.
                  • 34066 ☆ A M B ☆
                  • 23 Posts
                  Great info, thank you.. To answer the issue about google analytics cookies. use this to keep cookies on www:


                  var _gaq = _gaq || [];
                  _gaq.push(['_setAccount', 'UA-########-#'],
                  ['_setDomainName', 'www.valpocreative.com'],
                  ['_trackPageview']);
                    Tony Porto | Valpo Creative | http://www.valpocreative.com