Pages

Showing posts with label cakephp. Show all posts
Showing posts with label cakephp. Show all posts

Monday, February 4, 2013

Maintain Session across subdomain

To maintain your session variable across the subdomains in cakephp you need to do the following:

  1. Open app/config/bootstrap.php
  2. Add "ini_set('session.cookie_domain', '.domain.com');" 
By default Cake is creating a cookie for each domain. With this you can use same sessions across subdomains.




Tuesday, March 6, 2012

Include file in CakePHP

To include a file in your .ctp files, make the path is given from webroot. So if you have placed your file outside the "app" directory then the path will be set as include("../../file.php");

Monday, January 23, 2012

Integrating wordpress and cakephp

In one of my recent project I had a task of integrating Cakephp with Wordpress. The content pages had to be in Wordpress and other dynamic features were coming from CakePHP.

While trying to call Cakephp from wordpress or vice versa I was getting errors like "Fatal error: Cannot redeclare __()". These are mainly because of namespace conflict as Wordpress and Cakephp use some functions with same name.

CakePHP defines its functions in cake/basics.php. When Wordpress is integrated the file wp-includes/l10n.php gets included and has the same function names which results in fatal error.

The alternative is to add:

if ( !function_exists('__') ) :
// the function
endif;


for wordpress functions.

But I tried a different work around.
I kept wordpress and app folder of cakephp on root folder. To use same wordpress theme across the website I moved the header and footer.php outside of theme folder and kept in root.
So that the layout of cakephp also calls same header and footer.

Then I changed the .htaccess file to handle wordpress and cakephp related links separately.

This solved the fatal error issue and I was able to use wordpress and cakephp together in my website without any rework.