Extract (ever) correct domain name for cookie – php function

This function extract and return, the correct domain name for any passed value.

Get ever the correct cookie domain name, iterating into array only one time:

switch if on localhost:

(on WP_w3all plugin phpBB/WP)

Get complete Domains Names list updated at runtime (array)

The more convenient code that i’ve find out in mind, to get in any case, the correct cookie domain name, where many other different ways fails.
I do not think: but asking myself if there is possibility to have the same result, in less code and more fast than this.

All Domains Names updated at runtime (array)