phpsocketstcpphp-socket

Do TCP protocol also deal with cookies as HTTP protocol do?


I am planning to use php socket for my project. It needs user login to populate the content based on the session. So my question is that TCP/IP protocol also send/receive cookies for each and every request as HTTP protocol do or no i have to implement cookies system by myself. My project is not dependent on browser, it is like an application that will communicate through socket.

Can anyone explain in easy words?

Thanks in advance.


Solution

  • So my question is that TCP/IP protocol also send/receive cookies for each and every request as HTTP protocol do

    No. Cookies are defined by the HTTP protocol. Some other protocols have similar concepts, but there is nothing equivalent in TCP itself. TCP doesn't really have a concept of a "request" either; there is only a connection, and data flowing across it.

    (TCP does have a feature known as SYN cookies, but this is completely unrelated to HTTP cookies.)

    You may want to consider using the WebSockets protocol. WebSockets runs over HTTP, and as such can take advantage of some features of HTTP, including cookies.