<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def cookie(self, k, v, expires=None, domain=None, path='/', secure=False):
 """ Sets cookie value. :param k: Name for cookie value :param v: Cookie value :param expires: Cookie expiration date :param domain: Cookie domain :param path: Cookie path :param secure: Flag for `https only` :type k: str :type v: str :type expires: datetime.datetime :type domain: str :type path: str :type secure: bool """

        ls = ['{}={}'.format(k, v)]

        if expires is not None:
            dt = format_date_time(mktime(expires.timetuple()))
            ls.append('expires={}'.format(dt))

        if domain is not None:
            ls.append('domain={}'.format(domain))

        if path is not None:
            ls.append('path={}'.format(path))

        if secure:
            ls.append('secure')

        return self.header('Set-Cookie', '; '.join(ls), False)