0

Suppose the domain I am working on is www.example.com and it has a link shop which takes the user to subdomain shop.example.com

Now on shop.example.com when user add product to cart the the cart information is stored in $_SESSION['prd'] variable.

This session variable is available and count of cart items is perfectly displayed in shop.example.com but problem arises when i go to example.com then this session variable is not there.

I tried adding below line at the end of .htaccess

php_value session.cookie_domain ".example.com"  

but this gives 500 error.

4
  • possible duplicate of Preserving session variables across different domains Commented May 22, 2015 at 9:30
  • @saty This should be a lot easier since shop.example.com and www.example.com are on the same domain, and on the same server. Commented May 22, 2015 at 9:32
  • @Gags Go to your Apache error log and read what error it gives you. Internal server errors always log something that lets you figure out how to solve it. Commented May 22, 2015 at 9:34
  • how to access it on cpanel? Commented May 22, 2015 at 9:52

2 Answers 2

1

As simple as it may seem did you try removing the quotes from around your subdomain?

php_value session.cookie_domain .example.com

I've not got the complete solution working yet, but this at least doesn't give any errors.

Sign up to request clarification or add additional context in comments.

Comments

0

I had a similar problem, however, this solution was good for me, perhaps will help others in the future

edit you php.ini

session.cookie_domain = ".exemple.com"

or in you script php

session_set_cookie_params(0, '/', '.example.com');

session_start();

if you have problems try add this in your php.ini

suhosin.session.cryptdocroot = Off

suhosin.cookie.cryptdocroot = Off

1 Comment

Please, observe what and how to answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.