CakePHP projects Session not working - php

I've to CakePHP projects like:
project1 (main domain: http://www.example1.com)
/app
...
/project2 (sub folder domain: http://www.example2.com)
When hitting url for project1 it's working fine, but when visiting the project2, the $this->Session->write() isn't working, ie. Session is not working.
Write now this is session to project2/app/Config/core.php:
Configure::write('Session', array(
'defaults' => 'php',
'cookie' => 'project2_cookie_service',
//'timeout' => 525949
));
Please help me to resolve this issue.

In your app/Config/core.php change Session.cookie to another name. Your root project takes the default name CAKEPHP so change it for the sub-domain project to get another session.
From the following resource, you are able to change session save path of the project2 to prevent interference between it and project1 :
Configure::write('Session', array(
'defaults' => 'php',
'ini' => array(
'session.cookie_path' => '/app/dir'
)
));
Checkout this official resource

Related

How to allow auto login into Yii1 app once authenticated from Yii2 App

I am creating a main hub using Yii2 as a base, my goal is to ask users to login into the Yii2 app and store a session into a certain folder. Then inside the Yii2 app there will be links into older Yii1 apps that use stored session in a folder.
I have successfully made both apps start to store sessions into a specific folder in C://sessions but to no avail i couldn't get the Yii1 app to recognize the session that the Yii2 app has created.
My question is how do i allow auto login into the Yii1 app after the user has logged into the Yii2 app?
The configs below have not been successful as i cant seem to get the Yii1 app to recognize the session created by the Yii2 app. Is it even possible for them to share the same session?
Any help is greatly appreciated.
Yii2 - web.php
'components' => [
'session'=>[
'class'=>'yii\web\Session',
'savePath'=>"C:\sessions", //change session path
'timeout' => 600,
'cookieParams'=>[
'domain' => $_SERVER['HTTP_HOST'],
'expire' => 600
],
],
Yii1 - main.php
'components'=>array(
'session'=>array(
'class'=>'CHttpSession',
'savePath'=>"C:\sessions", //change session path
'cookieMode'=>'allow',
'timeout' => 600,
'cookieParams'=>array(
'domain' => $_SERVER['HTTP_HOST'],
'expire' => 600
),
),

How to setup Yii2 module on subdomain correctly?

I have a project on Yii2 advances app. And I have created a module named 'sale' on front end, Where I have extended layouts of frontend. And now I just want to access that module as a subdomain like http://sale.example.com .
I have created subdomain sale.example.com and set it's document root to root folder public_html (sites's root folder).
I have configures my urlManager like 'http://sale.example.com' => 'sale/default/index', according to Yii2 DOC. And it working fine but all my navigation gone wrong. I mean I think app's homeUrl is not pointing to default site url. My entire url system is changed after sub domains like http://sale.example.com/contact, But this is supposed to be http://example.com/contact . Here is a snapshot.
Thanks in Advance.
You can do it using UrlManager. Here is example Just replace your_module_name with real name of your module. More on UrlManager you can see here
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'enableStrictParsing' => false,
'rules' => [
'sale.example.com/<controller>/<action>' => 'your_module_name/<controller>/<action>',
],
],

Trying to get started with Zend Framework 1.12.7

Hi guys I am having a lot of trouble getting started with Zend Framework 1.12. Basically I've managed to get my project set up in Netbeans and I have it located on my localhost. When I go to this URL I get the default page:
http://localhost/zendtest2/application/views/scripts/index/index.phtml
But when I go to this page I get a list of my file tree in the localhost directory
http://localhost/zendtest2/
I guess what I am trying to understand is how to I get the http://localhost/zendtest2/ to point to the http://localhost/zendtest2/application/views/scripts/index/index.phtml or is that how I would even do it?
I know there is a public folder in my project with an index.php file. Is there some way that I should be reaching that page when the project initially starts?
To me this sounds more like an environment issue rather than a zend framework issue. I am not entirely sure what your dev environment is, but I am going to assume you're using apache as your HTTP server:
https://wiki.apache.org/httpd/DirectoryListings
Again, I am not entirely sure what OS you're using so you'll need to find your httpd.conf file yourself.
You then have two options, adding the redirect/route there (that may be wrong) or (more recommended) uncommenting the httpd-vhosts.conf link:
# Virtual hosts
#Include /private/etc/apache2/extra/httpd-vhosts.conf
Then including the new route in there. Heres a basic example (again you'll need to add what you need):
<VirtualHost *:8888>
ServerName zf2-tutorial.localhost
DocumentRoot "/Users/stevenc/****DIR_STUFF****/skeleton-application/public"
</VirtualHost>
Anything beyond that can be set as your home route in the module.config.php of the Application module within your zend project:
'router' => array(
'routes' => array(
'home' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'BookList\Controller\Book',
'action' => 'index',
),
),
),
Also, if you're not using ZF 1.12 for any particular reason, ZF2.3* is the latest.

Project folder is taken as controller in zend project

I am setting a demo Zend project on a windows server.
That is having base url like http://example.com/JPZend/public/
But on some url like http://example.com/JPZend/public/user/index?page=2
it gives the following page not found error where http://example.com/JPZend/public/user runs perfectly.
Page not found
Exception information:
Message: Invalid controller specified (JPZend)
Request Parameters:
array (
'controller' => 'JPZend',
'action' => 'public',
'user' => 'index',
'module' => 'default',
'page' => '2',
)
What am I missing? Seems like some virtual hosting issue?
Normally, you use the public folder as your webroot.
So your URL would look like this: http://example.com/JPZend
The default route in ZF is:
:controller/:action
Or with Modules enabled:
:module/:controller/:action
To tell ZF that you have another Base URL, you need to add a line to you application.ini:
resources.frontController.baseUrl = /JPZend/public
And to your .htaccess or similar under windows:
RewriteEngine on
RewriteBase /JPZend/public
Have fun!

URL cannot be found on the server for my FuelPHP Module

I'm creating a small FuelPHP application that contains a blog module. In this module the posts controller just assigns a simple view to the template for the posts index.
I have read through the FuelPHP docs and have the following settings in the app config for the modules:
'module_paths' => array(
APPPATH.'modules'.DS,
APPPATH.'..'.DS.'globalmods'.DS
),
'always_load' => array(
'packages' => array(
'auth',
'orm',
),
'modules' => array(
'admin',
'blog',
),
),
The application itself is outside my WAMP www docroot but the assets, htaccess and index.php are inside.
I have no idea why the server cannot find the localhost/blog/posts/index URL as I have followed everything advised on the docs and the homepage (root route) seems to display fine. It is only when I click the blog link (blog/posts/index) that it states
"Not Found
The requested URL /blog/posts/index was not found on this server."
Any help would be much appreciated!
I had the same problem myself. Two key things I did were:
1) Start with a fresh copy of Fuel. I was missing some sort of configuration file, so I create a brand new Fuel framework, and then added all the app files back in
2) Enabling the 'rewrite_module' in the Apache Modules (in the Wampserver config)
Try these two things and see what you get.

Categories