User logout automatically when the browser is closed
Okay, I changed the cookie_lifetime: 2000000 to 0 in local.services.yml file.

Then set the cookie in php by giving the last 2 arguments as 'true' ,this makes the cookie to be httponly and secure.

Thanks for your reference.