0

I am trying to integrate two websites build in wordpress and codeigniter. What I am trying to do here is is, I have user login in wordpress site. Here is the site. Now when the user logins here, and they access the dashboard, there is a navigation menu which will lead them to codeigniter site, which will be in the same host, say same folder or wherever it should be. When user clicks that navigation, they should be redirected to that site,and there user with the session in wordpress can only access. I read this, this and this but none meet my requirement. Can anyone tell me how can this be done.

EDIT This is what I did exactly, as far I could understand with my little knowledge from the reference of this answer. here

  function wp_magic_quotes() {
// If already slashed, strip.
if ( get_magic_quotes_gpc() ) {
    $_GET    = stripslashes_deep( $_GET    );
    $_POST   = stripslashes_deep( $_POST   );
    $_COOKIE = stripslashes_deep( $_COOKIE );
}

// Escape with wpdb.
$_GET    = add_magic_quotes( $_GET    );
$_POST   = add_magic_quotes( $_POST   );
// $_COOKIE = add_magic_quotes( $_COOKIE );
array_walk($_COOKIE, 'ci_ignore_magic_quotes');
$_SERVER = add_magic_quotes( $_SERVER );

// Force REQUEST to be GET + POST.
$_REQUEST = array_merge( $_GET, $_POST );
      }


    /** added by me
   * Applies Magic Quotes to the $_COOKIE global but ignores Codeigniter's 
  Cookie
  * @param  string $value Value passed by array_walk function
  * @param  string $key   Key passed by array_walk function
   */
    function ci_ignore_magic_quotes($value,$key)
     {
    if($key != "ci_session")
     {
    stripslashes_deep($value);
    }
   }

And I simply printed this in ci controller;

  public function index()
{
    print_r($_SESSION);exit;

    $this->load->view('welcome_message');
}

It is returning this:

  Array ( [__ci_last_regenerate] => 1504085777 )

Is this what the things should had happen? I am trying to integrate this wp and ci for the very first time. So please help with whatever you can. Thanks.

Tekraj Shrestha
  • 1,228
  • 3
  • 20
  • 48
  • 1
    Explain _how_ the stuff you found does not “fit your requirement”. – CBroe Aug 30 '17 at 08:27
  • Have you set Sessions in your site and it's not working ? Or do you just need to know the best way to do it ? – SH_ Aug 30 '17 at 09:34
  • 1
    @SH_ can you please see my edit above? – Tekraj Shrestha Aug 30 '17 at 09:43
  • @SH_ And Can you provide me the reference or hints to do in the best way? I just want is after the user logs into wp site, and if the user navigates to CI page, the session generated in wp site should be accessible and with it I should be able to give access to that particular user – Tekraj Shrestha Aug 30 '17 at 09:46
  • When you print the session there is a codeigniter reference `[__ci_last_regenerate] => 1504085777` as you can see. What I can't see is any $_SESSION variables set in wordpress. I don't know how Wordpress sets/unsets $_SESSION variables however, if you can set one in wordpress (eg. `$_SESSION['__user_logged_in'] = 1;`) and then re-print in Codeigniter maybe you will see it in the Array ? – SH_ Aug 30 '17 at 10:05
  • @SH_ okay I will try that and will inform you. – Tekraj Shrestha Aug 30 '17 at 10:26

0 Answers0