Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9003179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:40:47+00:00 2026-06-16T00:40:47+00:00

Hello I have developed a small menu bar in jsp which collects attribute of

  • 0

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 ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:40:48+00:00Added an answer on June 16, 2026 at 12:40 am

    You need to access the session using $_SESSION superglobal. You may call session_start(); before that to start the session if not already started.

    <?php $myname =  $_SESSION['name'];           
    if (!empty($myname) && $myname != 'admin'): ?>
        <a href="logout.jsp" ><span>Logout</span></a></li>
        <li><span>Welcome <?php echo $myname; ?></span></li>
    <?php else if (!empty($myname) && $myname == 'admin'): ?>
        <a href="logout.jsp" ><span>Logout</span></a></li>
        <li><span>Welcome Admin</span></li>
    <?php endif; ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have string which rich text content something like this for example <p>Hello</p> <br/>
Hello I have developed my first application for Android using the Ice Cream Sandwich
I have developed the Hello World Android application using Eclipse. I can run the
I developed very simple Hello World EJB (3.x) which I deployed on JBoss 7.1.
Based on PlatformLibrary sample code in the SDK, I have created a small hello
Hello we have developed our first enterprise app recently. We are using the In-House
I have developed a haskell application which is tested with WinHugs interpreter working fine
I have developed an applet java with Eclipse, which is included in MyPage.html. I
Hello Guys !! I developed a small application to send mail to particular id
Hello friends i have developed game application on facebook. I have to post random

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.