cookie vs token

We all have doubts about what to use when implementing authentication at client side,whether I save the token I get from the server as cookie or should i use the local storage of browser. Here I will point out some of the differences between cookie and token. You can decide what fits more into your application.

Cookie
Token
Automatically included in all requests
We must manually include in the requests
Cookie is unique to each domain. We have different cookies for amazon, eBay, google etc.
We can send token to any domain
Requset:
Headers
Cookie:{}
Body{
Name:’ABc’
}
Requset:
Headers
Authorization:’adbdghgber495yjfkhjhl’
Body{
Name:’AB’
}
Cookies bring state to stateless http protocol

Cors

CORS introduces a standard mechanism that can be used by all browsers for implementing cross-domain requests. The spec defines a set of headers that allow the browser and server to communicate about which requests are (and are not) allowed. CORS continues the spirit of the open web by bringing API access to all.

Err address in use

this error occurs when we are using a port and try to bind the same port again. I have this error when I was using react and using 9080 port and tried to run server on same port. We have to kill the process first and then we have to bind the port again.

In windows you can use the following command to kill all instances of node server running

taskkill /f /im node.exe

AJAX

AJAX is acronym for Asynchronous JavaScript and XML. Ajax makes it possible to send and receive data asynchronously without reloading the web page. In general web applications the client(browser) is blocked when we refresh the page as it makes use of synchronous requests. But with Ajax the client is not blocked and works independently. Web applications like gmail, facebook etc make use of AJAX .