[ Video Sharing CMS v4 ] 2nd Install under a subdomain + shared user database

Started by Rafa,

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

RafaTopic starter

Hi Mario,
I have my initial install under the my main domain and it works like it should. Now, I am tryingto accomplish 2 things:

1. Add a second install under a subdomain (subdomain.mymaindomain.com) in such a way that both installs use the same user table (vibe_users).

2. Both installs share user sessions/cookies (so the user doesn't have to log in twice.

Have you come across this scenario before? Do you know of a way this could be done?

Please advise.
Thank you
  •  

Marius P.

Hi,
not really.

I am very bad personally with cookies and sessions, I don't know if they could be shared.

But, you should have the exact same Cookie security data under login settings, first thing.


the lib/functions.php the function


//fix cookie 
function cookiedomain() {
$parse = parse_url(site_url());
return '.'.str_replace('www.','', $parse['host']);
}



set to make the cookie active for all subdomains (google it maybe?)


As for quering the same database...it would need alteration on the sql queries for users like:
Database.Schema.Table when referencing tables
Database.Schema.Table.Column when referencing columns
this in the subdomain importing from the other.
But this is kinda funky, why not just make an cron which checks if new users exist and copies them over? Also use php's copy() to bring the thumbnails over and covers.
Or better yet on access to site if cookie exists but user is not in database, import him fully from the other table
lib/functions.php


public static function LoginbyPass($full) {
global $db;
if($full && !empty($full)){
list($id, $pass) = explode(COOKIESPLIT, user::decrypt($full, SECRETSALT));
if(isset($id) && isset($pass) && $id && $pass) {
$id = intval($id);
$result = $db->get_var("SELECT id FROM ".DB_PREFIX."users WHERE id ='" . sanitize_int($id). "' and pass ='" .toDb($pass) . "'");
if($result && !empty($result)) {
user::LoginUser($result);
}
}
}
}



changed to something like:


public static function LoginbyPass($full) {
global $db;
if($full && !empty($full)){
list($id, $pass) = explode(COOKIESPLIT, user::decrypt($full, SECRETSALT));
if(isset($id) && isset($pass) && $id && $pass) {
$id = intval($id);
$result = $db->get_var("SELECT id FROM ".DB_PREFIX."users WHERE id ='" . sanitize_int($id). "' and pass ='" .toDb($pass) . "'");
if($result && !empty($result)) {
user::LoginUser($result);
} else {
//Import user 
//Select user from the other database
//Insert it onto this one.
// and again
user::LoginUser($newresult);
}
}
}
}



If you need the full code, let me know and I will try to test some for you, but for now really busy with finishing the plan for 4.0
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

RafaTopic starter

Thank you Mario.
As always great tips. I'll spend some time on that and let you know how it will turn out.
  •  

RafaTopic starter

Mario, do I need to use a difference license Key of the subdomain installation?
Thanks.
  •  

Marius P.

Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

Similar topics (7)