Reputation: 139
I am trying to conditionally display some html where I want to check the value passed from my server, against my local storage value. I can't figure out how to get access to this local storage value.
<% for(var i=0; i < list.length; i++) { %>
<%
checkUser = function(passed_in_UID) {
return(passed_in_UID == localStorage.getItem("UID"));
};
%>
<% if(checkUser(list[i].val().UID)) { %>
<p>Show this tag if conditional true</p>
<% } %>
<% } %>
I keep getting internal 500 error because I guess localStorage isn't valid in ejs. How do I grab this value then?
Upvotes: 3
Views: 2825
Reputation: 20526
Local Storage is browser specific. EJS runs on the server side (server side rendering), therefor local storage is not accessible from your server. You could use some form of database to store non secret data and use EJS on your server side. But unless somehow you share the data between the two server data is separate from client data.
Upvotes: 3