Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7720023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:33:38+00:00 2026-06-01T03:33:38+00:00

I have 2 sites that are the same, but different databases and data. One

  • 0

I have 2 sites that are the same, but different databases and data. One site is http://www.somesite.com and the other is sub.somesite.com. What I am doing is if someone logs into http://www.somesite.com and the login details don’t match http://www.somesite.com, but they do match sub.somesite.com, then use cURL to submit the information and log them in. I have the cURL working great:

foreach($_POST as $key=>$p) {
  if ($post != "") {
    $post .= "&";
  }
  $post .= $key."=".$p;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://sub.somesite.com"); 
curl_setopt($ch, CURLOPT_POST, count($_POST));
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt"); 
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
$cArray = curl_getinfo($ch);
$newURL = $cArray[url];
echo str_replace('</head>','<base href="'.$newURL.'" /></head>',$result);
curl_close($ch);

What this does is collects the post variables, submits them to the other site and adds a base url so that the paths are correct.

The problem that I am having is any other page after. So say I am on somesite.com, submit the data. Even though it is going to sub.somesite.com/welcome.php, it displays in the address bar somesite.com and the information is stored in the cookies.txt. Now when I click a link (sub.somesite.com/page2.php) on sub.somesite.com/welcome.php, it redirects to the login page because the sessions are in the cookies.txt and now aren’t accessible.

How would I make the sessions continue to work on all pages?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T03:33:40+00:00Added an answer on June 1, 2026 at 3:33 am

    It is because CURL executes it on the server not on the client (browser). Your server might have the users cookies but the user does not.

    You want to set the cookies for the browser using setcookie and forget about the Curl.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 54 sites that have different URLS but use the exact same codeigniter
I am wanting to have the EXACT same data across two WordPress sites that
James here. I'm working on a site that I want to have the same
I have several sites that I want to link back to the main site
I have third party sites that link to some images on my site. The
I have a tab layout on one of my sites that shows a log
Using SQL Server 2008 (R2). I have two tables in different databases (with same
I have seen that many other people are having the same issue as me,
I have two sites that are app1 and app2. If a user requests a
I have a few client sites that have a width of about 900px-1000px centered,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.