-1

I have the following code:

<?php
session_start();
$cexp=time()+(60*60*24*3650);
setcookie('cookie_jamepush','cookie_content',$cexp ,'/');
echo 'cc='.$_COOKIE['cookie_jamepush'];
$_SESSION['user']='hello';
echo 'ss='.$_SESSION['user'];
?>

This code works properly for the website it was created for.

However, I have two websites that are running on a common server. The above code works on one, but doesn't work on the other.

How can I resolve this problem?

Bono
  • 4,757
  • 6
  • 48
  • 77
  • This link may have some info to help, http://stackoverflow.com/questions/20417642/what-happens-if-session-name-is-same-on-two-different-websites. You may need to have unique session names for each website to avoid session conflicts. – Sgt AJ May 16 '16 at 14:41
  • Are the two websites on the same web server? – Webomatik May 16 '16 at 15:41

1 Answers1

0

It is impossible. You can share cookies only in subdomains.

Sharing cookies across different domains and different applications (classic ASP and ASP.NET)

If you want to use sessions in different hosts, you should make database sessions

Community
  • 1
  • 1
Javid Aliyev
  • 436
  • 4
  • 11