使用相同的IP地址保存2个PHPSESSID访问计算机

Server is WAMP. I have 2 sugarcrm sites, one for production say, saved at www/folder1 , other for development say saved at www/folder2 . I am accessing them using IP address (say 66.102.0.0/folder1 and 66.102.0.0/folder2 ) . Browser saves 1 cookie (PHPSESSID) for both of them. If I login/logout to first site, it effects other site also. I can create subdomain at localhost like folder1.localhost and folder2.localhost but how IP based sub-domain is possible like, folder1.66.102.0.0 and folder2.66.102.0.0 (looks funny :) ) ?Or can I use different port for different folder, like 66.102.0.0:80 and 66.102.0.0:8080 ?Then will browser saved 2 cookies, if port is different on same ip address?I can't change login/logout, it's sugarcrm not core php. I can use different browsers but my boss is saying to make cookies separately. Or is there any browser Add-on that separates cookies based on folder?

Call session_set_cookie_params() to restrict the cookie to a particular folder:

$params = session_get_cookie_params();
session_set_cookie_params($params['lifetime'], '/folder1');
session_start();

Yes. Creating subdomains should solve your problem. I do this all the time.

If you are opening your site as 66.102.0.0 then your session is based on that url which is causing all the problems.

Note: Directories mentioned here are windows wamp specific but as long as you find the appropriate files, this applies to Apache in all OS's.

Step 1. Uncomment this line in your bin/apache/Apache*.*.*/conf/httpd.conf

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

Step 2. Make a virtual host entries in your bin/apache/Apache*.*.*/conf/extra/httpd-vhosts.conf file.

NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot "D:/wamp/www"
    ServerName localhost
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" common
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "D:/wamp/www/folder1"
    ServerName folder1.localhost
    ErrorLog "logs/folder1.localhost-error.log"
    CustomLog "logs/folder1.localhost-access.log" common
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "D:/wamp/www/folder2"
    ServerName folder2.localhost
    ErrorLog "logs/folder2.localhost-error.log"
    CustomLog "logs/folder2.localhost-access.log" common
</VirtualHost>

Step 3. Restart wampserver / apache.

Step 4. Edit your hosts file. C:\Windows\System32\drivers\etc\hosts

Add in the entries.

127.0.0.1 folder1.localhost # You probably want 66.102.0.0 over here instead of 127.0.0.1
127.0.0.1 folder2.localhost