Access localStorage from ejs template

I am trying to save some data sent by the server to an EJS template in localStorage on the client side. However, when I try to access localStorage in the template, I get localStorage is undefined.

Here is a part of my page.ejs:

<% localStorage.setItem('info', JSON.stringify({'user': user})) %>

where user is a value received from the server.

Is this possible?