I'm a bit lost at the moment. I'm trying to use both the Cookies and
the Session components in the same setting and I'm not sure, but it
doesn't appear to be working correctly.

What I want to be able to do is this: I want to be able to set a
Session cookie for a visitor to keep track of their current session.
But I would also like to keep a "first session" Cookie stored on their
computer to be able to see if the person coming to the site has been
originally referred to us by someone we're trying to keep track of
(advertisments, etc). The problem I'm running into is that it appears
as though Mac and Windows computers are interpreting the cookies in
two different ways, both of them wrong.

On the Windows system, every time I hit the refresh button, it comes
up with a new session ID. On the Mac system, it's coming up with the
same Session ID even after having closed out the browser.
Additionally, I noticed that in FireBug the cookies are all coming up
with the value "Session" for the expiration time (FireCookie).

        /*
        // checkSession:                Checks for an existing session history 
cookie and
sets a new session.
        */
        public function checkSession() {
                $first  = intval($this->Cookie->read('first_session.id'));
                $last   = intval($this->Session->read('session.id'));
                $ip             = $this->RequestHandler->getClientIP();
                // No current Session cookie, make one:
                if($last < 1) :
                        // Create a new Session in the database:
                        $session_data = array('SessionVisit' => 
array('first_sessionid' =>
$first, 'host_addr' => $ip));
                        $this->SessionVisit->save($session_data);
                        $sess = $this->SessionVisit->getLastInsertId();
                        // If there was no first_session cookie set, we do so 
now:
                        if($first < 1) :
                                $this->Cookie->write('first_session.id', $sess);
                                $this->Cookie->write('first_session.ip', $ip);
                        endif;
                        // Store Session ID and visitor IP address in the 
session cookie:
                        $this->Session->write('session.id', $sess);
                        $this->Session->write('session.ip', $ip);
                endif;
        }

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

Reply via email to