Lazy Sessions in CakePHP

88 views
Skip to first unread message

Simon East

unread,
Jul 14, 2013, 7:25:03 PM7/14/13
to cakeph...@googlegroups.com
Has anyone ever attempted to implement "lazy sessions" in CakePHP?  I tried googling it and came up with zero.  I'm interested in attempting it, and wondered whether it may be something that we could possibly implement into Cake 3 (is there a release time-frame for that yet?).

What I mean by "lazy sessions" is that a session cookie is not sent to the client if you're simply attempting to READ from the session, only when you WRITE to it.  This means that anonymous users on your site don't get the cookie, and it's easier to cache those pages with Varnish or whatever else.  When a user logs in, they get a session cookie, and then those pages may be individualised.

This StackOverflow question discusses it somewhat:
http://stackoverflow.com/questions/2998166/how-should-i-implement-lazy-session-creation-in-php

Anyone have any thoughts or experience with doing this?


Simon East   Technical Lead  |  surfacedigital
Level 1, 60 Hardware Lane, Melbourne VIC 3000 Australia
Ph 
(03) 9670 7062   
Skype simoneast_oz   Tw @surfacedigital   www.surfacedigital.com.au


Ravage84

unread,
Jul 15, 2013, 11:55:27 AM7/15/13
to cakeph...@googlegroups.com
Hi Simon,

Have you seen this?
https://cakephp.lighthouseapp.com/projects/42648/tickets/3124-add-option-for-disabling-the-auto-starting-of-sessions#ticket-3124-30

May be you can join the discussion and even contribute some code?

Ciao
Marc

Simon East

unread,
Jul 15, 2013, 9:28:29 PM7/15/13
to cakeph...@googlegroups.com
Oh yeah, thanks Marc.  I had replied to that issue last year, but had forgotten about it.  If others think it would be beneficial, I'd be happy to contribute some code when I get some time to put something together.



Simon East   Technical Lead  |  surfacedigital
Level 1, 60 Hardware Lane, Melbourne VIC 3000 Australia
Ph 
(03) 9670 7062   
Skype simoneast_oz   Tw @surfacedigital   www.surfacedigital.com.au




--
You received this message because you are subscribed to the Google Groups "cakephp-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cakephp-core...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

mark_story

unread,
Jul 16, 2013, 12:39:36 PM7/16/13
to cakeph...@googlegroups.com
One of the difficulties in doing a lazy start is handling the various situations, and limitations in PHP. If you don't start the session when trying to read it, your reads will fail. You might be able to work around this issue by poking about in $_COOKIE for the session cookie though. For some reason I remember the session cookie not showing up in $_COOKIE though.

-Mark
Reply all
Reply to author
Forward
0 new messages