Re: disabling cache when a user is logged

2010-02-01 Thread djogo
Euromark, I think that __construct is the first thing that runs in Any
class, so sessions are avaliable in all methods.

I thought of using it at bootstrap, but there the session is
unavailable...


On 31 jan, 20:29, euromark dereurom...@googlemail.com wrote:
 this will never work
 the session is initialized in __construct() of the app controller
 therefore not available until beforeFilter() in any controller

 the session will not be present at that time yet
 or am i mistaken?

 On 31 Jan., 22:09, majna majna...@gmail.com wrote: dirty way (not tested)
  in app/config/bootstrap.php

  check if user is logged in, like:

  if (isset($_SESSION['User']['id])) {
     Configure::write('Cache.check', false);

  }

  On Jan 31, 11:32 am, Lorenzo Bettini bett...@dsi.unifi.it wrote:

   Hi

   in my AppController I've enabled cache for view and index actions and
   they work fine.

   Now, I'd like to disable cache when a user is logged, since in that case
   additional information are shown that must not be cached.

   Thus I added the method

           function beforeRender() {
                   if ($this-is_logged_user()) {
                           // disable cache when the user is logged, since 
   some information
                           // must NOT be cached, e.g., private papers
                           $this-cacheAction = array();
                   }
           }

   where is_logged_user is a function that checks whether a user is logged.

   This works in the sense that no cache is used when a user is browsing
   the site.  However, if the user visits an action page which has already
   been cached then he will get the cached page, which I want to avoid as
   well...  is there a way to avoid this?

   I've also tried with $this-disableCache() but that does not work.

   The only solution I see is to clear the cache, but I'd want to avoid 
   that...

   thanks in advance
           Lorenzo

   --
   Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
   HOME:http://www.lorenzobettini.itMUSIC:http://www.purplesucker.com
   BLOGS:http://tronprog.blogspot.com http://longlivemusic.blogspot.com

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: disabling cache when a user is logged

2010-02-01 Thread AD7six


On Jan 31, 11:32 am, Lorenzo Bettini bett...@dsi.unifi.it wrote:
 Hi

 in my AppController I've enabled cache for view and index actions and
 they work fine.

 Now, I'd like to disable cache when a user is logged, since in that case
 additional information are shown that must not be cached.

 Thus I added the method

         function beforeRender() {
                 if ($this-is_logged_user()) {
                         // disable cache when the user is logged, since some 
 information
                         // must NOT be cached, e.g., private papers
                         $this-cacheAction = array();
                 }
         }

 where is_logged_user is a function that checks whether a user is logged.

 This works in the sense that no cache is used when a user is browsing
 the site.  However, if the user visits an action page which has already
 been cached then he will get the cached page, which I want to avoid as
 well...  is there a way to avoid this?

 I've also tried with $this-disableCache() but that does not work.

 The only solution I see is to clear the cache, but I'd want to avoid that...

Why not change the cached view folder (in the bootstrap) based on the
presence or not of a session cookie.

OR directly use http://github.com/mcurry/html_cache if appropriate

hth,

AD

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: disabling cache when a user is logged

2010-02-01 Thread AD7six


On Feb 1, 10:56 am, AD7six andydawso...@gmail.com wrote:
 On Jan 31, 11:32 am, Lorenzo Bettini bett...@dsi.unifi.it wrote:





  Hi

  in my AppController I've enabled cache for view and index actions and
  they work fine.

  Now, I'd like to disable cache when a user is logged, since in that case
  additional information are shown that must not be cached.

  Thus I added the method

          function beforeRender() {
                  if ($this-is_logged_user()) {
                          // disable cache when the user is logged, since 
  some information
                          // must NOT be cached, e.g., private papers
                          $this-cacheAction = array();
                  }
          }

  where is_logged_user is a function that checks whether a user is logged.

  This works in the sense that no cache is used when a user is browsing
  the site.  However, if the user visits an action page which has already
  been cached then he will get the cached page, which I want to avoid as
  well...  is there a way to avoid this?

  I've also tried with $this-disableCache() but that does not work.

  The only solution I see is to clear the cache, but I'd want to avoid that...

 Why not change the cached view folder (in the bootstrap) based on the
 presence or not of a session cookie.

 OR directly usehttp://github.com/mcurry/html_cacheif appropriate

 hth,

 AD

PS disabling cache app-wide (Configure::write('Cache.check', false); )
is a fantastic way to make your app really slow. The cache is used for
things like where are my files and what tables are in my db, so
choose your solution with caution ;)

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: disabling cache when a user is logged

2010-02-01 Thread Lorenzo Bettini
the real problem is that beforeRender is not called if the page is 
present in the cache...  any idea of where to put such control?


thanks in advance
Lorenzo

djogo wrote:

Euromark, I think that __construct is the first thing that runs in Any
class, so sessions are avaliable in all methods.

I thought of using it at bootstrap, but there the session is
unavailable...


On 31 jan, 20:29, euromark dereurom...@googlemail.com wrote:

this will never work
the session is initialized in __construct() of the app controller
therefore not available until beforeFilter() in any controller

the session will not be present at that time yet
or am i mistaken?

On 31 Jan., 22:09, majna majna...@gmail.com wrote: dirty way (not tested)

in app/config/bootstrap.php
check if user is logged in, like:
if (isset($_SESSION['User']['id])) {
   Configure::write('Cache.check', false);
}
On Jan 31, 11:32 am, Lorenzo Bettini bett...@dsi.unifi.it wrote:

Hi
in my AppController I've enabled cache for view and index actions and
they work fine.
Now, I'd like to disable cache when a user is logged, since in that case
additional information are shown that must not be cached.
Thus I added the method
function beforeRender() {
if ($this-is_logged_user()) {
// disable cache when the user is logged, since some 
information
// must NOT be cached, e.g., private papers
$this-cacheAction = array();
}
}
where is_logged_user is a function that checks whether a user is logged.
This works in the sense that no cache is used when a user is browsing
the site.  However, if the user visits an action page which has already
been cached then he will get the cached page, which I want to avoid as
well...  is there a way to avoid this?
I've also tried with $this-disableCache() but that does not work.
The only solution I see is to clear the cache, but I'd want to avoid that...
thanks in advance
Lorenzo
--




--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
BLOGS: http://tronprog.blogspot.com  http://longlivemusic.blogspot.com

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: disabling cache when a user is logged

2010-02-01 Thread Jeremy Burns
Could you use cake:nocache/cake:nocache in the right places? See 
http://book.cakephp.org/view/347/Marking-Non-Cached-Content-in-Views

Jeremy Burns


On 1 Feb 2010, at 12:36, Lorenzo Bettini wrote:

 the real problem is that beforeRender is not called if the page is present in 
 the cache...  any idea of where to put such control?
 
 thanks in advance
   Lorenzo
 
 djogo wrote:
 Euromark, I think that __construct is the first thing that runs in Any
 class, so sessions are avaliable in all methods.
 I thought of using it at bootstrap, but there the session is
 unavailable...
 On 31 jan, 20:29, euromark dereurom...@googlemail.com wrote:
 this will never work
 the session is initialized in __construct() of the app controller
 therefore not available until beforeFilter() in any controller
 
 the session will not be present at that time yet
 or am i mistaken?
 
 On 31 Jan., 22:09, majna majna...@gmail.com wrote: dirty way (not tested)
 in app/config/bootstrap.php
 check if user is logged in, like:
 if (isset($_SESSION['User']['id])) {
   Configure::write('Cache.check', false);
 }
 On Jan 31, 11:32 am, Lorenzo Bettini bett...@dsi.unifi.it wrote:
 Hi
 in my AppController I've enabled cache for view and index actions and
 they work fine.
 Now, I'd like to disable cache when a user is logged, since in that case
 additional information are shown that must not be cached.
 Thus I added the method
function beforeRender() {
if ($this-is_logged_user()) {
// disable cache when the user is logged, since 
 some information
// must NOT be cached, e.g., private papers
$this-cacheAction = array();
}
}
 where is_logged_user is a function that checks whether a user is logged.
 This works in the sense that no cache is used when a user is browsing
 the site.  However, if the user visits an action page which has already
 been cached then he will get the cached page, which I want to avoid as
 well...  is there a way to avoid this?
 I've also tried with $this-disableCache() but that does not work.
 The only solution I see is to clear the cache, but I'd want to avoid 
 that...
 thanks in advance
Lorenzo
 --
 
 
 
 -- 
 Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
 HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
 BLOGS: http://tronprog.blogspot.com  http://longlivemusic.blogspot.com
 
 Check out the new CakePHP Questions site http://cakeqs.org and help others 
 with their CakePHP related questions.
 
 You received this message because you are subscribed to the Google Groups 
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
 http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: disabling cache when a user is logged

2010-02-01 Thread AD7six


On Feb 1, 1:36 pm, Lorenzo Bettini bett...@dsi.unifi.it wrote:
 the real problem is that beforeRender is not called if the page is
 present in the cache...  any idea of where to put such control?

How is that different than your initial question.

Why not change the cached view folder (in the bootstrap) based on
the
presence or not of a session cookie.  means define TMP and related
constants yourself, based on whatever logic you want, before cake
does.

see http://github.com/cakephp/cakephp1x/blob/1.3/cake/config/paths.php#L174

OR use mark currys awesome cache helper, which effectively does this
for you.

AD

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: disabling cache when a user is logged

2010-02-01 Thread Lorenzo Bettini

I tried to put this in bootstrap.php

session_start();
debug($_SESSION);

and I get an empty array, so this does not work...

isn't really no way to get control before the cache read is performed?

Lorenzo

djogo wrote:

Euromark, I think that __construct is the first thing that runs in Any
class, so sessions are avaliable in all methods.

I thought of using it at bootstrap, but there the session is
unavailable...


On 31 jan, 20:29, euromark dereurom...@googlemail.com wrote:

this will never work
the session is initialized in __construct() of the app controller
therefore not available until beforeFilter() in any controller

the session will not be present at that time yet
or am i mistaken?

On 31 Jan., 22:09, majna majna...@gmail.com wrote: dirty way (not tested)

in app/config/bootstrap.php
check if user is logged in, like:
if (isset($_SESSION['User']['id])) {
   Configure::write('Cache.check', false);
}
On Jan 31, 11:32 am, Lorenzo Bettini bett...@dsi.unifi.it wrote:

Hi
in my AppController I've enabled cache for view and index actions and
they work fine.
Now, I'd like to disable cache when a user is logged, since in that case
additional information are shown that must not be cached.
Thus I added the method
function beforeRender() {
if ($this-is_logged_user()) {
// disable cache when the user is logged, since some 
information
// must NOT be cached, e.g., private papers
$this-cacheAction = array();
}
}
where is_logged_user is a function that checks whether a user is logged.
This works in the sense that no cache is used when a user is browsing
the site.  However, if the user visits an action page which has already
been cached then he will get the cached page, which I want to avoid as
well...  is there a way to avoid this?
I've also tried with $this-disableCache() but that does not work.
The only solution I see is to clear the cache, but I'd want to avoid that...
thanks in advance
Lorenzo
--



--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
BLOGS: http://tronprog.blogspot.com  http://longlivemusic.blogspot.com

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: disabling cache when a user is logged

2010-02-01 Thread AD7six


On Feb 1, 2:00 pm, Lorenzo Bettini bett...@dsi.unifi.it wrote:
 I tried to put this in bootstrap.php

 session_start();
 debug($_SESSION);

print_r($_COOKIE); die;

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: disabling cache when a user is logged

2010-02-01 Thread Lorenzo Bettini

AD7six wrote:


On Feb 1, 2:00 pm, Lorenzo Bettini bett...@dsi.unifi.it wrote:

I tried to put this in bootstrap.php

session_start();
debug($_SESSION);


print_r($_COOKIE); die;



Array ( [CAKEPHP] = ... [PHPSESSID] = ... )

that's all, no other useful information...

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
BLOGS: http://tronprog.blogspot.com  http://longlivemusic.blogspot.com

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: disabling cache when a user is logged

2010-02-01 Thread Lorenzo Bettini

Jeremy Burns wrote:
Could you use cake:nocache/cake:nocache in the right places? 
See http://book.cakephp.org/view/347/Marking-Non-Cached-Content-in-Views




I already do this for some parts of the layout (e.g., showing the 
currently logged user), but I need it for the whole contents, and, as 
far as I know, this is not possible: from the manual


It should be noted that once an action is cached, the controller method 
for the action will not be called - otherwise what would be the point of 
caching the page. Therefore, it is not possible to wrap cake:nocache 
/cake:nocache around variables which are set from the controller as 
they will be null.


cheers
Lorenzo



--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
BLOGS: http://tronprog.blogspot.com  http://longlivemusic.blogspot.com

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


disabling cache when a user is logged

2010-01-31 Thread Lorenzo Bettini

Hi

in my AppController I've enabled cache for view and index actions and 
they work fine.


Now, I'd like to disable cache when a user is logged, since in that case 
additional information are shown that must not be cached.


Thus I added the method

function beforeRender() {
if ($this-is_logged_user()) {
// disable cache when the user is logged, since some 
information
// must NOT be cached, e.g., private papers
$this-cacheAction = array();
}
}

where is_logged_user is a function that checks whether a user is logged.

This works in the sense that no cache is used when a user is browsing 
the site.  However, if the user visits an action page which has already 
been cached then he will get the cached page, which I want to avoid as 
well...  is there a way to avoid this?


I've also tried with $this-disableCache() but that does not work.

The only solution I see is to clear the cache, but I'd want to avoid that...

thanks in advance
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
BLOGS: http://tronprog.blogspot.com  http://longlivemusic.blogspot.com

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: disabling cache when a user is logged

2010-01-31 Thread majna
dirty way (not tested)
in app/config/bootstrap.php

check if user is logged in, like:

if (isset($_SESSION['User']['id])) {
   Configure::write('Cache.check', false);
}



On Jan 31, 11:32 am, Lorenzo Bettini bett...@dsi.unifi.it wrote:
 Hi

 in my AppController I've enabled cache for view and index actions and
 they work fine.

 Now, I'd like to disable cache when a user is logged, since in that case
 additional information are shown that must not be cached.

 Thus I added the method

         function beforeRender() {
                 if ($this-is_logged_user()) {
                         // disable cache when the user is logged, since some 
 information
                         // must NOT be cached, e.g., private papers
                         $this-cacheAction = array();
                 }
         }

 where is_logged_user is a function that checks whether a user is logged.

 This works in the sense that no cache is used when a user is browsing
 the site.  However, if the user visits an action page which has already
 been cached then he will get the cached page, which I want to avoid as
 well...  is there a way to avoid this?

 I've also tried with $this-disableCache() but that does not work.

 The only solution I see is to clear the cache, but I'd want to avoid that...

 thanks in advance
         Lorenzo

 --
 Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
 HOME:http://www.lorenzobettini.itMUSIC:http://www.purplesucker.com
 BLOGS:http://tronprog.blogspot.com http://longlivemusic.blogspot.com

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: disabling cache when a user is logged

2010-01-31 Thread euromark
this will never work
the session is initialized in __construct() of the app controller
therefore not available until beforeFilter() in any controller

the session will not be present at that time yet
or am i mistaken?


On 31 Jan., 22:09, majna majna...@gmail.com wrote:
 dirty way (not tested)
 in app/config/bootstrap.php

 check if user is logged in, like:

 if (isset($_SESSION['User']['id])) {
    Configure::write('Cache.check', false);

 }

 On Jan 31, 11:32 am, Lorenzo Bettini bett...@dsi.unifi.it wrote:

  Hi

  in my AppController I've enabled cache for view and index actions and
  they work fine.

  Now, I'd like to disable cache when a user is logged, since in that case
  additional information are shown that must not be cached.

  Thus I added the method

          function beforeRender() {
                  if ($this-is_logged_user()) {
                          // disable cache when the user is logged, since 
  some information
                          // must NOT be cached, e.g., private papers
                          $this-cacheAction = array();
                  }
          }

  where is_logged_user is a function that checks whether a user is logged.

  This works in the sense that no cache is used when a user is browsing
  the site.  However, if the user visits an action page which has already
  been cached then he will get the cached page, which I want to avoid as
  well...  is there a way to avoid this?

  I've also tried with $this-disableCache() but that does not work.

  The only solution I see is to clear the cache, but I'd want to avoid that...

  thanks in advance
          Lorenzo

  --
  Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
  HOME:http://www.lorenzobettini.itMUSIC:http://www.purplesucker.com
  BLOGS:http://tronprog.blogspot.com http://longlivemusic.blogspot.com

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en