integration of codeigniter and wordpress authorization
Is there an easy way to integrate two auth functions between codeigniter and wordpress. I am not sure how to do this, or the best procedure. They are both residing on the same server. I am looking at something maybe similar to the way that youtube and google work together. I am not sure if this is possible. I have managed someth开发者_运维技巧ing with a php application a while ago (not codeigniter), but if I could use that it would be also ideal. It wont implement with codeigniter though. I am not even sure how safe it is but i can paste it below. Codeigniter stores variable in a database on my app as well. I can access them, is there a way I can use these variables??
require('../wp-config.php');
auth_redirect();
is_user_logged_in();
wp_get_current_user();
global $current_user;
global $mysql, $username;
global $auth;
$username = $current_user->user_login;
I have just added a script that can access the database session in codeigniter. Dont know if any good, but I dont know how to impliment this or if it is relevant.
require_once("config.php");
$cisess_cookie = $_COOKIE['ci_session'];
$cisess_cookie = stripslashes($cisess_cookie);
$cisess_cookie = unserialize($cisess_cookie);
$cisess_session_id = $cisess_cookie['session_id'];
$cisess_connect = mysql_connect(MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_PASSWORD);
if (!$cisess_connect) {
die("<div class=\"error\">" . mysql_error() . "</div>");
}
$cisess_query = "SELECT user_data FROM ci_sessions WHERE session_id = '$cisess_session_id' LIMIT 1";
mysql_select_db(MYSQL_DATABASE, $cisess_connect);
$cisess_result = mysql_query($cisess_query, $cisess_connect);
if (!$cisess_result) {
die("Invalid Query");
}
$cisess_row = mysql_fetch_assoc($cisess_result);
$cisess_data = unserialize($cisess_row['user_data']);
print_r($cisess_data);
You might be able to use a library like IonAuth (http://codeigniter.com/wiki/Ion_Auth_-_Lightweight_Auth_System/) as a starting point. It's been a while since I used IonAuth last but I think you could portably get this working just by editing the settings in the config file that comes with IonAuth.
精彩评论