Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

Cookie-free domains

Started by sugizo 9 years ago · 10 replies · 5380 views
9 years ago

I would be interested in disabling session cookies, too. Also there is a setting session.enabled in user/config/system.yaml, setting it to false throws an error ("Server Error ... 0 - The Login plugin requires "system.session" to be enabled"). Since the login plugin is required if using the admin UI, it's not possible to disable session cookies even for pages not containing any form.

However, it should be possible to suppress session cookies for regular web pages not containing forms, shouldn't it? Pages with forms such as login pages could override the session.enabled setting explicitly or implicitly.

last edited 10/23/17 by Stefan
9 years ago

You could use different environments. Use 'admin.yoursite.com' with cookies and disable cookies for yoursite.com.

9 years ago

i've followed the step in the link above:

  • analyze all of static files using gtmetrix.com
  • create a subdomain (e.g. static.domain.com) and move all of static files into the subdomain folder (e.g. static.domain.com folder)
  • update my theme url link that serve static files into my new subdomain (e.g. static.domain.com/styles.min.css)
  • recheck again on gtmetrix.com, the result is static files still in cookie domain while the static url is point to subdomain (e.g. static.domain.com/styles.min.css)

any idea how to achieve it in grav way?

@chris_jung
how to disable cookies in grav?

thanks and best regards,
stifan

9 years ago

@sugizo:
how to disable cookies in grav?

As I wrote in my reply, set session.enabled to false in user/config/system.yaml to disable cookies.

9 years ago

@chris_jung:
You could use different environments. Use ‘admin.yoursite.com’ with cookies and disable cookies for yoursite.com.

Problem are restricted and contact pages in the yoursite.com domain still requiring session cookies. It would be possible to just enable session for those pages, but if I understand it correctly, code in the login plugin has to be changed for this, since the login plugin checks for the session.enabled setting globally (file user/plugins/login/login.php, lines 69-72).

last edited 10/24/17 by Stefan
8 years ago

Finally I just commented "throw new \RuntimeException('The Login plugin requires "system.session" to be enabled');" on line 81 (file user/plugins/login/login.php) and set session.enabled to false in user/config/system.yaml.

In fact the system only checks if session is enabled to get "an authorization".
If you don't check system.session, the login plugin will create the session too.

8 years ago

Much easier since Grav 1.4.6:
set
system session.enabled to true and
system session.initialize to false

👍 1
8 years ago

I also am interested in creating a cookie-free site (because I don't see why it would need one and GDPR makes cookies a bit of a hassle). I just tried what you suggested @arank, but the grav-site cookie still pops up again. I tried clearing the cache but to no avail. How do I get rid of that cookie?

EDIT: I am so sorry! I uploaded it into the wrong directory… 😅 Now that's fixed, the cookie is gone and everything is working like a charm. So thank you very much @arank!

last edited 07/24/18 by Anna
6 years ago

I tried this because I only want cookies when login plugin is being used and not for anonymous users, but ticking box remember me results in error page and not ticking it doesn't get you logged in. Am i missing something here?

The reason I want this is because I am picking a fight with Varnish...as a trial-and-error-dude I really shouldn't, but I can't let go

/forum/general/could-use-a-bit-of-help-with-varnish-pages-remain-uncached-t3924

Suggested topics

Topic Participants Replies Views Activity
General · by Jerry Hunt, 4 days ago
2 80 9 hours ago
General · by pamtbaau, 14 hours ago
1 51 13 hours ago
General · by Andy Miller, 1 day ago
0 44 1 day ago
General · by Marcel, 12 months ago
6 346 5 days ago
General · by Duc , 5 days ago
3 40 5 days ago