Answer the question
In order to leave comments, you need to log in
How to get to a variable from any template?
You have to pass a value from different handler functions to each template!
Example:
//MainHandler
user := session.Get("userInfo")
//...
template.Execute(wr, struct{"user", user})
//-------------------------
//ProfileHandler
user := session.Get("userInfo")
//...
template.Execute(wr, struct{"user", user})
//------------------------------
// и т.д.
//при регистрации установили в сессию юзерИнфо
$_SESSION['userInfo'] = $userInfo;
//потом в любом шаблоне берем данные
<div><?=$_SESSION['userInfo']['username']?></div>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question