by ComputerGuru · 6y ago · 0 comments
So, no, certainly not equal complexity.
Authentication and session management across a network can be accomplished across a variety of ways. Operating systems prefer Kerberos for remote authentication. Cookies are preferred by developers who fear JavaScript precisely because because they can be written and transmitted without need for JavaScript. The same end result, authentication and session management, can be accomplished with the same complexity without cookies. Complexity refers to the number of steps involved and not the challenge imposed upon the developer.
https://en.wikipedia.org/wiki/Complexity
The only reason to prefer an out-dated functionally obsolete technology is fear of disruption. I have explained all this already, please see the comment I linked to from above: https://news.ycombinator.com/item?id=23098196
JavaScript is absolutely not intended to function as a core part of merely making authenticated web requests between the browser and the server. I’m saddened by how often I need to explain this.
JavaScript is a general purpose high level language that happens to natively run in the browser. My original point is that cookies are functionally obsolete and still in frequent use because developers are generally afraid of JavaScript. The more this conversation divests from authentication towards JavaScript the more credibility you lend my original opinion.
It’s the same level of complexity either way because whether you use cookies or some other storage mechanism the business requirements around authentication remain the same the and the steps to accomplish those requirements are not so drastically different.
It’s like saying “the reason people don’t use apple juice to make mimosas and continue to use obsolete oranges is because they’re irrationally afraid of apple peelers.”
Do you see how many things are wrong in that statement?
You seem to believe that developers should always chose the most complex and intricate solution possible, and the only reason someone would chose a simpler solution would be due to incompetence or ignorance of the more complex solution.
This is completely opposite of all good engineering practice. Complexity is not a goal, it is a liability. You want to have the minimum amount of complexity which solves the problem.
Using cookies, the browser automatically sends the identifier token along with the initial request, and the server can serve the initial response based on your identity.
With localStorage, the browser initially send an anonymous request to the server, the server then have to return some bootstrap JavaScript which reads the identity token from localStorage and then passes it to the server in the next request, and only then the server can respond based on your identity.
By any reasonable definition, the second approach is more complex, not to mention slower and more fragile.