Dynadot

Keeping Users logged in between Wordpress subdirectory and main site

Spaceship Spaceship
Watch
Impact
467
I am wanting to figure out how to keep members logged in between my primary website and a WP blog in a subfolder.

I have already setup the wordpress external authentication plugin so that people are only registering/logging in via my primary websites database and that seems to work fine..... but the issue i am having is that being logged in doesn't carry over between the main site and the wp site. I can log in fine via the wp page using my main site credentials but, if I navigate back to the main website, I am not registered as logged in and the same goes if I am logged in via the main site and then navigate to the subfolder blog, am no longer recognized as an already logged in user.

I have done a lot of looking around hoping to find some plugn dealing with this, since it seems like enough people would want to provide a simple "log in once" option for members between a main website and blog, but surprisingly could not find one. So hoping that it is indeed something easy, not even warranting a plugin, that I didn't think of and that some wp guru knows what needs to be done, via auth cookies or whatnot so that when a member is logged in via the main site they will be recognized as a logged in member on the wp blog too.....
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
anyone that has done this who can give some tips?
 
0
•••
What is your main website? Something custom coded?

Is this the plugin you're using?
http://wordpress.org/plugins/external-db-auth-reloaded/

It seems your logins are still both separate, your main website only sets it's login session/cookies and the wordpress one only sets its own.

This is the wordpress login function
http://codex.wordpress.org/Function_Reference/wp_signon

If your login script is getting the username/password you use this

Code:
require_once('blog/wp-includes/user.php.');
$creds = array();
	$creds['user_login'] = 'example';
	$creds['user_password'] = 'plaintextpw';
	$creds['remember'] = true;
	$user = wp_signon( $creds, false );
	if ( is_wp_error($user) )
		echo $user->get_error_message();

Without more info it's hard to say more.
 
2
•••
thanks chicken for taking the time to read the issue and give your input!

yes, I am using that plugin and seems to be working, is accessing the login data from my primary sites DB and all.... just isn't recognizing it if i am logged in and come over to the subfolder...

so this code you gave, do I use it as is or need to plugin whatever the column headers are in my main login table for user_login and plaintextpw?

and where do i put this code, in the wp install or my main site somewhere?

thanks for the help!
 
Last edited:
0
•••
First of all to reduce the confusion you can just forget about plugins over here.

It is a simple solution.

Put

<?php
foreach($_SESSION as $key=>$value)
{
echo "$key - $value<br />";
}
?>

At the top of the header file in WP.

Now you will be able to see how your sessions are working on this side.

Just use same/similar sessions/sessionnames on the other side of the script and it will all work out nicely.

Now you can just remove that foreach thing from the header file.

Thanks.
 
0
•••
thanks chicken for taking the time to read the issue and give your input!

yes, I am using that plugin and seems to be working, is accessing the login data from my primary sites DB and all.... just isn't recognizing it if i am logged in and come over to the subfolder...

so this code you gave, do I use it as is or need to plugin whatever the column headers are in my main login table for user_login and plaintextpw?

and where do i put this code, in the wp install or my main site somewhere?

thanks for the help!

You could use that on your custom site, the require_once would need to point to wherever your wordpress installation is.

You should be grabbing those 2 values from the login form after you've authenticated the user.
 
0
•••
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back