SMF Forum SESSION not working inside the CakePHP controller

Started by chinmay235, March 03, 2015, 06:38:08 AM

Previous topic - Next topic

chinmay235

Last 3 days i have tried to login both Cakephp and smf forum with a single login form. I can't find any solution. Please check my topic -

I have successfully login in my SMF forum account. I need to get all the forum session inside my CakePHP controller.


Directory Structure -
    ->Controller
      ->UsersController.php
    ->webroot
      ->forum
         ->SSI.php
      ->forum_session.php




forum_session.php
include('forum/SSI.php');
print_r($_SESSION);



Output: - www.domainname.com/forum_session.php [nofollow]
    Array
    (
        [session_value] => 83beb751176ff11f49a4f9235e171e28
        [session_var] => c548044f77c7
        [mc] => Array
            (
                [time] => 1425379079
                [id] => 33
                [gq] => 0=1
                [bq] => 0=1
                [ap] => Array
                    (
                    )
   
                [mb] => Array
                    (
                    )
   
                [mq] => 0=1
            )
   
        [ban] => Array
            (
                [last_checked] => 1425379080
                [id_member] => 33
                [ip] => 127.0.0.1
                [ip2] => 127.0.0.1
                [email] => [email protected]
            )
   
        [log_time] => 1425379079
        [timeOnlineUpdated] => 1425379069
        [old_url] => http://www.domainname.com/forum/index.php
        [USER_AGENT] => Mozilla/5.0 (Windows NT 5.1; rv:35.0) Gecko/20100101 Firefox/35.0
        [login_SMFCookie956] => a:4:{i:0;s:2:"33";i:1;s:40:"a5928c2b1665a1d6e9784a06bd2baa38d7ec2d99";i:2;i:1425382679;i:3;i:3;}
        [id_msg_last_visit] => 1
        [unread_messages] => 0
    )



UsersController.php

    public function login() {
        if ($this->Session->read('Auth.User')) {
            $this->redirect(array('controller'=>'users','action'=>'index'));
        } else {
    //session_destroy();
    //$getLoginId = file_get_contents(HTTP_ROOT.'custom_api.php?login');
    include_once('forum/SSI.php');
    pr($_SESSION);
            //Auth login here...
        }
    }



Output: - www.mydomainname/users/login

    Array
    (
        [visited_page] => /
        [session_value] => 89419f580643d3aa47731501f32787bf
        [session_var] => ff665d2d
        [mc] => Array
            (
                [time] => 1425379431
                [id] => 0
                [gq] => 0=1
                [bq] => 0=1
                [ap] => Array
                    (
                    )
   
                [mb] => Array
                    (
                    )
   
                [mq] => 0=1
            )
   
        [USER_AGENT] => Mozilla/5.0 (Windows NT 5.1; rv:35.0) Gecko/20100101 Firefox/35.0
        [login_url] => http://www.domainname.com/users/login
        [logout_url] => http://www.domainname.com/users/logout
        [captcha] => priapic
    )


After login i got above output both smf and cakephp. But i am not getting my accurate result in cakephp.

Please solve and how to show my smf session data in cakephp controller?

chinmay235


margarett

Hi

I'm sorry that you had no reply. This is the kind of issue that not many people have the knowledge required to help you with.

I also don't have it :P but here goes nothing ;D

AFAIK, you can only have 1 active session. So, if your CakePHP generates a session, SMF will not be able to generate its own. That's why your second session output is totally different from the first one.
You should even get a warning in PHP, I think (not really sure about that).

So, if you want to integrate the logins, you should do it in a different way.
My suggestion is for you to check the recent bridge WP --> SMF --> https://github.com/xchwarze/WP2SMFBridge
You will see that, when a user logs in into WP, it generates the necessary SMF data, including the necessary cookie. And that, IMO, is the correct way to do it ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

chinmay235

I saw your link. But this code developed in Wordpress. I need CakePhp :(

Suki

Its the same principle.

A quick search on their site: http://bakery.cakephp.org/articles/dirhauge/2007/10/31/cakephp-smf  which is still valid for SMF, I don't know if it is still valid for cakephp though.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

chinmay235

Quote from: Suki on March 12, 2015, 10:39:06 AM
Its the same principle.

A quick search on their site: http://bakery.cakephp.org/articles/dirhauge/2007/10/31/cakephp-smf [nofollow]  which is still valid for SMF, I don't know if it is still valid for cakephp though.

This code I have used. This is for older version. CakePHP 2.x not supported this code. :(
I googled I am not getting satisfy answer.

Suki

Perhaps if you provide more info?  starting with the cakephp version you are using.

Are you familiar with cakephp? are you looking for someone to do the script for you or just a guide to do it yourself?
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Advertisement: