• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
codeigniter session to third party site

#1
[eluser]xeroblast[/eluser]
hi,

i need your help on how to take the codeigniter sessions to be use as post data in another site such as phpbb or wordpress or joomla which are put in the iframe.

this is what i had in mind, the main site, which is codeigniter, where the user login its username and password. and this username and password is the same with the third party site like the phpbb or wordpress or joomla. so when user logins in codeigniter, the user is also automatically login to these sites using the username and password in the codeigniter.

i have a simple idea using the jquery post [$.post('3rdparty/login.php', post-data-here)] but i must work on the codeigniter controller which i have no idea on how to do it.

thanks for the help in advance.

#2
[eluser]toopay[/eluser]
@xeroblast,

Iam not clear with your question there. But, if i correctly get what you are trying to do, i will do that this way :

1. In your MAIN codeigniter application, you could have a specific controller function, that act as some "Cookie" observer, basically something like this :
Code:
public function status()
{
   $cookie = $this->session->all_userdata();
   $userdata = json_encode($cookie, TRUE);

   $content = 'var origin_cookie = '.$userdata.';';

   $this->output->set_content_type('js');
   $this->output->set_output($content);
}

2. Then from your "child" application, you could get what is the user status atm within your main application, by adding this javascript part.

This, basically did not require any iframe element at all.

#3
[eluser]xeroblast[/eluser]
i have a main site (codeigniter), when a user logs-in to the main site, he/she is automatically logs-in to the phpbb and wordpress because i will remove the login page of phpbb and wordpress.

1. when user register to codeigniter, he/she is also be automatically register to phpbb & wordpress.
2. when user logs-in to codeigniter, he/she is also automatically login to phpbb and wordpress.
3. when user logs-out to codeigniter, he/she is also be automatically logout to phpbb and wordpress.

---------
can you explain what youre doing in the code you provided? i couldnt get what the code means to my problem.

thanks.

#4
[eluser]xeroblast[/eluser]
what i mean is something like this :

Code:
class controller_name extends CI {
function_name() {
  jquery.post("phpbb/ucp.php?mode=login", { username: $this->session->userdata('username'), password: $this->session->userdata('password') } );
}
}

the codeigniter session data are pass as $_POST to the phpbb.
this will login to the phpbb using the codeigniter session.

#5
[eluser]toopay[/eluser]
My approach above, is assumed your codeigniter application act as the main application. With above code i gave, you supposed to get the status of your user, against your codeigniter application (as main application) at that time. It similar with how Facebook, for example, utilize their widget.

One note, you COULD NOT, perform ajax post across different domain, since it countain a security risk. But reading cookie accross different domain, is possible, just like i show you above.

#6
[eluser]jamesduncan[/eluser]
[quote author="toopay" date="1330689294"]My approach above, is assumed your codeigniter application act as the main application. With above code i gave, you supposed to get the status of your user, against your codeigniter application (as main application) at that time. It similar with how Facebook, for example, utilize their widget.

One note, you COULD NOT, perform ajax post across different domain, since it countain a security risk. But reading cookie accross different domain, is possible, just like i show you above.[/quote]


Hi toopay

Thanks for posting this - I'm getting a 500 error im my console trying this code - I think I'm close though

I have your controller code in /applications/controllers/cookie.php

And have put your JS into my wordpress header /blog/wp-content/themes/my-theme/header.php

What is the path of the cookie_asset.setAttribute("src", 'http://mywebsite.com/cookie/status'); from you code that I should be using, given my structure outlined above?

Thanks!

#7
[eluser]toopay[/eluser]
[quote author="jamesduncan" date="1346265040"]
I have your controller code in /applications/controllers/cookie.php
[/quote]
Try access your codeigniter application from browser, it should be : http://your-ci-app.com/index.php/cookie/status

#8
[eluser]jamesduncan[/eluser]
When I try to access that URL on my site (with my domain name ofcourse)

I get a 500 error

"HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request."

Any ideas?

Thanks for getting back to me!

#9
[eluser]toopay[/eluser]
Check your web-server error log.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.