Friday, December 2, 2011

Re: Cakephp 2.0.3: Troubles with Sessions...

SOLVED: removing the ?> at the end of the controller solved the
problem. Weird.

On Nov 27, 7:30 pm, ava <avon...@gmx.net> 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 <dereurom...@googlemail.com> 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<avon...@gmx.net> 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
> > > <?php
> > > 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
> > > <?php
> > > class Test01 extends AppModel {
> > >    var $name = 'Test01';
> > >    var $useTable = false;}
>
> > > ?>
>
> > > // VIEW
> > > <?php
> > > echo $scounter;
> > > ?>
> > > <br/><a href="/test01s/testsession">testsession</a>
>
> > > // 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: