Re: Cakephp 2.0.3: Troubles with Sessions...

2011-12-02 Thread ava
SOLVED: removing the ?>  at the end of the controller solved the
problem. Weird.

On Nov 27, 7:30 pm, ava  wrote:
> @euromark
>
> how is the test case set up? Well, I call it several times by clicking
> on the link in the view.  I don't know if this answers your
> question...
>
> Anyway, I tried to get aSessionID, but this doesn't return a value:
>
> function testsession() {
>       if ($scounter = $this->Session->read('scounter')) {
>           $scounter++;
>       } else {
>           $scounter = 1;
>       }
>       $this->Session->write('scounter', $scounter);
>       $this->set('scounter', $scounter);
>
>       $this->log('SessionID: ' . $this->Session->id());      // no
> SessionID is outputed...
>
> }
>
> On Nov 27, 1:57 pm, euromark  wrote:
>
>
>
>
>
>
>
> > you can simplify the condition to
> > if ($scounter = $this->Session->read('scounter')) {}
>
> > but besides that
> > how is the test case set up?
> > because it is possible that it resets itself after each run
> > therefore thesessionwould always be emptied afterwards...
>
> > On 27 Nov., 11:38,ava wrote:
>
> > > Hi
>
> > > I'm struggling with sessions in cakephp 2.0.3.
>
> > > In this testcase the counter should be incremented with each click on
> > > the link.  The counter always remains 1.
>
> > > // CONTROLLER
> > >  > > class Test01sController extends AppController {
>
> > >    public $components = array('Session');
>
> > >    function testsession() {
> > >       $scounter = 1;
> > >       if ($this->Session->check('scounter')) {
> > >           $scounter = $this->Session->read('scounter');
> > >           $scounter++;
> > >       }
> > >       $this->Session->write('scounter', $scounter);
> > >       $this->set('scounter', $scounter);
> > >     }
>
> > > }
>
> > > //MODEL
> > >  > > class Test01 extends AppModel {
> > >    var $name = 'Test01';
> > >    var $useTable = false;}
>
> > > ?>
>
> > > // VIEW
> > >  > > echo $scounter;
> > > ?>
> > > testsession
>
> > > // CORE
> > > Configure::write('Session', array(
> > >     'defaults' => 'php',
> > >     'cookie' => 'vportal',
> > >     'ini' => array('session.gc_divisor' =>
> > > 1000,'session.cookie_httponly' => true),
> > >     'timeout' => 4320  //3 days
> > > ));
>
> > > I also dumped the $_SESSION array. This array is always empty.
>
> > > Any help or hints are appreciated.
>
> > > -- Andre

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Cakephp 2.0.3: Troubles with Sessions...

2011-11-27 Thread ava
@euromark

how is the test case set up? Well, I call it several times by clicking
on the link in the view.  I don't know if this answers your
question...

Anyway, I tried to get a Session ID, but this doesn't return a value:

function testsession() {
  if ($scounter = $this->Session->read('scounter')) {
  $scounter++;
  } else {
  $scounter = 1;
  }
  $this->Session->write('scounter', $scounter);
  $this->set('scounter', $scounter);

  $this->log('SessionID: ' . $this->Session->id());  // no
SessionID is outputed...
}



On Nov 27, 1:57 pm, euromark  wrote:
> you can simplify the condition to
> if ($scounter = $this->Session->read('scounter')) {}
>
> but besides that
> how is the test case set up?
> because it is possible that it resets itself after each run
> therefore the session would always be emptied afterwards...
>
> On 27 Nov., 11:38, ava  wrote:
>
>
>
>
>
>
>
> > Hi
>
> > I'm struggling with sessions in cakephp 2.0.3.
>
> > In this testcase the counter should be incremented with each click on
> > the link.  The counter always remains 1.
>
> > // CONTROLLER
> >  > class Test01sController extends AppController {
>
> >    public $components = array('Session');
>
> >    function testsession() {
> >       $scounter = 1;
> >       if ($this->Session->check('scounter')) {
> >           $scounter = $this->Session->read('scounter');
> >           $scounter++;
> >       }
> >       $this->Session->write('scounter', $scounter);
> >       $this->set('scounter', $scounter);
> >     }
>
> > }
>
> > //MODEL
> >  > class Test01 extends AppModel {
> >    var $name = 'Test01';
> >    var $useTable = false;}
>
> > ?>
>
> > // VIEW
> >  > echo $scounter;
> > ?>
> > testsession
>
> > // CORE
> > Configure::write('Session', array(
> >     'defaults' => 'php',
> >     'cookie' => 'vportal',
> >     'ini' => array('session.gc_divisor' =>
> > 1000,'session.cookie_httponly' => true),
> >     'timeout' => 4320  //3 days
> > ));
>
> > I also dumped the $_SESSION array. This array is always empty.
>
> > Any help or hints are appreciated.
>
> > -- Andre

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Cakephp 2.0.3: Troubles with Sessions...

2011-11-27 Thread euromark
you can simplify the condition to
if ($scounter = $this->Session->read('scounter')) {}

but besides that
how is the test case set up?
because it is possible that it resets itself after each run
therefore the session would always be emptied afterwards...



On 27 Nov., 11:38, ava  wrote:
> Hi
>
> I'm struggling with sessions in cakephp 2.0.3.
>
> In this testcase the counter should be incremented with each click on
> the link.  The counter always remains 1.
>
> // CONTROLLER
>  class Test01sController extends AppController {
>
>    public $components = array('Session');
>
>    function testsession() {
>       $scounter = 1;
>       if ($this->Session->check('scounter')) {
>           $scounter = $this->Session->read('scounter');
>           $scounter++;
>       }
>       $this->Session->write('scounter', $scounter);
>       $this->set('scounter', $scounter);
>     }
>
> }
>
> //MODEL
>  class Test01 extends AppModel {
>    var $name = 'Test01';
>    var $useTable = false;}
>
> ?>
>
> // VIEW
>  echo $scounter;
> ?>
> testsession
>
> // CORE
> Configure::write('Session', array(
>     'defaults' => 'php',
>     'cookie' => 'vportal',
>     'ini' => array('session.gc_divisor' =>
> 1000,'session.cookie_httponly' => true),
>     'timeout' => 4320  //3 days
> ));
>
> I also dumped the $_SESSION array. This array is always empty.
>
> Any help or hints are appreciated.
>
> -- Andre

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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