How do I check if something is not overlapping another thing

I wanted to change a global variable when an object is over lapping another object, and then change the global variable back to it's original state once the object is no longer overlapping the other object. How do I achieve this, if possible?