Friday, September 13, 2013

Sessions break.. Easy fix?

    As we all know, Sessions will NOT carry across domains(Unless you serialize all the data and start a new one on the other side using that data and some sort of Factory()). What then, can one do about users entering a site that choose to use http://www.example.com  Instead of example.com? For Example...

Lets say I send out a mass email and in it is the following link: 

http://www.myCakeSite.com/Do/Something

Assuming that some people are weary of clicking links inside of emails they may choose to type the link into their address bar like so:

myCakeSite.com/Do/Something

OR EVEN:

www.myCakeSite.com/Do/Something

PHP's session handler sees all of these as DIFFERENT domains.. So if the site has an internal link NOT mapped to a controller or action
ie.

'<a href="Blah.php" alt="Go to Blah">Read About Blah!!!</a>'

This destroys the session. Losing all data and user info in the process. 

QUESTION:
Is the only way around this to change ALL LINKS to map to a controller action? So instead it would be:

$this->redirect(array('controller' => 'read', 'action' => 'blah'));

Then create a view for each file needing to be rendered while retaining the session data?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: