title: How to check if a cookie is set in FastAPI?
body: <p>I defined an optional cookie parameter and now want to check if the cookie was set. Unfortunately, the variable does not equal to <code>None</code> but to an empty <code>Cookie</code> object. How can I check the cookie object if it is set?<br />
  Here's how I defined the cookie parameter:</p>
  <pre><code>@app.route(&quot;/graphcall&quot;)
  def graphcall(request: Request, ads_id: Optional[str] = Cookie(None)):
      if ads_id:
        # Do stuff if the ads_id is set
  </code></pre>