Posted in Interesting, Programming, Web Tech

Web cookie

You have been browsing the internet and chances are when you visit a website for the first time then for some of websites you may have come across a pop-up or a notification banner: “This website uses cookies” with buttons for accept and change settings. Sometimes you just say, Oh whatever that is! Let me just get into the website and press the Accept button to go about your way. So let us understand what is happening behind the scenes.

What is a web cookie?

Web cookie or browser cookie is a small piece of information which is send from website server to be stored in a user’s browser. The user may store it in its computer which is basically used to identify the computer. That is, maintain stateful information so the next time, user visits the website or on the next request it can send back, the cookie that can have some kind of information about the user that the server can make use of to make certain decisions. Other purposes could be for instance, track user’s browser activity or remember login details, track site’s user count etc.

Who invented it?

The term was coined by web browser programmer who invented cookie Lou Montulli in the year 1994 while building an e-commerce website.

Why do we see the cookie banner pop up?

The reason why we see the cookie banner popping up recently across most websites is because of legal concerns in Europe and some other countries, the GDPR(General Data Privacy Regulation) requires that the cookie banners be displayed on website to let the users know that cookies are being used by the website.

Where is a cookie useful?

Its used in session management to manage session of the user in ecommerce website. Its used for personalization like the settings that were set and saved by the user and as said earlier, also used for tracking to improve the user experience as they say it 😉

Posted in Interesting, Programming, Softwares, Web Tech

Because…”this” is not that

Yes! You read it right. This is not that in Javascript and otherwise.

The this keyword in javascript can be confusing for a naive JS learner. Its behaviour varies depending on the execution context. In general, this refers to the object under current execution.

  • this, when used alone refers to a global object.
var a = this;
console.log(x);

A browser window

  • this, when used in an object method, refers to owner of the object method.
var car = {
 model: BMW,
 colour: black,
 details: function(){
    return this.model + " " + this.colour;
 }
};

this refers to the car object. The car object is owner of its properties and methods.

console.log(car.details());
BMW black
  • this, when used in a function refers to a global object
function testFunction() {
  return this;
}

returns the global object [object Window]. However, in strict mode, the above testFuntion returns undefined

  • this, when used in event handling

refers to the html DOM element on which the event listener is placed

Click here!

alerts with button tag name.

Posted in Interesting, Programming, Web Tech

Quirks mode & Standard mode

Quirk in general means peculiarity or characteristic. In order to maintain backward compatibility for web pages designed for older versions of some of the browsers which does not comply to standards of W3C(World Wide Web Consortium )and IETF(Internet Engineering Task Force). Its a non-standard mode.

The recent browser follow a standard mode which complies with W3C wherein the behaviour is as per HTML and CSS specifications. For HTML documents browsers use a DOCTYPE at the beginning of the document for handling the webpage in standard mode. <!DOCTYPE html> provides the purpose of activating the full standard mode.