Both the client and the server send headers. Among the headers that clients send are cookies, in the “Cookie:” header.
Setting cookies doesn’t make them available in the script you set them in, because cookies are headers. The headers have already been sent.