(N/A) Chlorine is obtained as a by-product in the electrolysis of molten $NaCl$ and in the electrolysis of brine $(NaCl_{(aq)})$ in the Chlor-alkali process.
In the electrolysis of molten $NaCl$:
At anode: $2Cl^-_{(melt)} \longrightarrow Cl_{2(g)} + 2e^-$
At cathode: $2Na^+_{(melt)} + 2e^- \longrightarrow 2Na_{(s)}$
If an aqueous solution of $NaCl$ (brine) is subjected to electrolysis,$Cl_2$ gas is obtained at the anode,but at the cathode,$H_2$ gas is evolved instead of $Na$ metal. This is because the standard reduction potential of $Na^+$ $(E^{\circ} = -2.71 \ V)$ is much more negative than that of $H_2O$ $(E^{\circ} = -0.83 \ V)$. Therefore,$H_2O$ is preferentially reduced at the cathode.
At cathode: $2H_2O_{(l)} + 2e^- \longrightarrow H_{2(g)} + 2OH^-_{(aq)}$
At anode: $2Cl^-_{(aq)} \longrightarrow Cl_{2(g)} + 2e^-$