Solved

PHP Expire Sub Domain Cookies

Posted on 2014-04-15
5
260 Views
Last Modified: 2014-05-12
I have control over abc.domain.com and I want to add a logout link to my site that will log users out of abc.domain.com and xyz.domain.com. Is this possible, or do I only have control over cookies from abc.com? If so, how would I expire the xyz cookie?
0
Comment
Question by:dale_abrams
  • 3
  • 2
5 Comments
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 40002883
Subdomains are controllable. What is the actual domain you're using?  The setcookie() function has subdomain-level control.  See the "domain" argument in the online man page.  You would set this subdomain-level cookie with an expiration date/time in the past.
0
 
LVL 1

Author Comment

by:dale_abrams
ID: 40032953
Thanks for the response Ray. It turns out that setcookie() is not able to administrate a cookie on xyz.domain.com if the user is on abc.domain.com. The sub domains are treated as being completely different domains and browsers block the ability to cross reference other cookies.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 40032968
Can you please post the SSCCE that illustrates that?  I'll be glad to test it out to see if there is a workaround.  It might be possible to remove domain.com, thereby removing both abc.domain.com and xyz.domain.com, however this might only be possible if the cookie was originally set for domain.com - a recondite conundrum.
0
 
LVL 1

Author Closing Comment

by:dale_abrams
ID: 40059922
I wasn't able to get this working with your suggestion, but as the only one to attempt to help me, you deserve the points. Thanks Ray.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 40060073
Why didn't you answer my requests for information?  Why did you give the worst possible grade anyone can give a fellow colleague at EE?  Please explain and tell me what you expected from me that you did not get?
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video teaches users how to migrate an existing Wordpress website to a new domain.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now