if cookie and not cookie.isspace():
# the string is non-empty
# the string is empty
The above takes in consideration the cases where the string is None or a sequence of white spaces.
Hope it works!!
If you are a beginner and need to know more about Python, It's recommended to go for Python Certification course today.