Hello I have developed a small menu bar in jsp which collects attribute of a session and displays menu according to it.
<li><%
String myname = (String)session.getAttribute("name");
if(myname!=null && !myname.equals("admin")) {
%>
<a href="logout.jsp" ><span>Logout</span></a></li>
<li><span>Welcome <%=myname%></span></li>
<%
}
else if(myname!=null && myname.equals("admin"))
{
%>
<a href="logout.jsp" ><span>Logout</span></a></li>
<li><span>Welcome Admin</span></li>
I want this same code in php .I tried it but in vain as I am newbie to php.So my question is how to get session attribute as name and password, in php ?
You need to access the session using $_SESSION superglobal. You may call session_start(); before that to start the session if not already started.