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

970 Views Asked by At

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.

3

There are 3 best solutions below

2
On BEST ANSWER

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.

0
On

HTTP is an application protocol that's nested in a TCP payload. If you want to use raw TCP, you may devise your own communication scheme. Since you ask about cookies, you might need some persistence. The cookies are implemented as HTTP headers. You can still use HTTP without involving a browser. That way you can leverage many HTTP servers and server-side scripting languages.

0
On

Cookies are implemented only on application layer (http). There is no need of cookie as such in tcp because for every tcp connection there exits a tuple socket pair composed of client ip and port number, server ip and port number. These socket pairs are unique and determines the client uniquely. However same is not through with http because http doesn't maintain the record of client ip address or client port number etc... Only purpose of http is to serve the client. So in order to uniquely define the client, http uses cookies and session ID. This helps http to figure out the purpose of data sent by client and serve accordingly.