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 7722603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:13:27+00:00 2026-06-01T04:13:27+00:00

ExpressionEngine template code: <div class=container_16> <div class=grid_16> {if {segment_1} == home} {embed=include/title title=welcome} {if:elseif

  • 0

ExpressionEngine template code:

<div class="container_16">
  <div class="grid_16">
{if "{segment_1}" == "home"}
  {embed="include/title" title="welcome"}
{if:elseif "{segment_1}" == "login"}
  {embed="include/title" title="login"}
{if:else}
<?php
  if(isset($_SESSION['loggedin'])) {
    if($_SESSION['loggedin']) {
?>
      {embed="include/title" title="welcome"}
<?php
    } else {            
?>    
      {embed="include/title" title="login"}
<?php 
    }
  }
?>          
{/if}
  </div> <!-- grid_16 -->
</div> <!-- container_16 -->

The problem I’m having with the code above is that when segment_1 is empty,
I want it to show the title template with the embed title=login only if the
$_SESSION[‘loggedin’] is not true.

I KNOW that the session variable is not even set so it should show the title
template with login but it is not showing anything except this:

<div class="container_16">
  <div class="grid_16">

  </div> <!-- grid_16 -->
</div> <!-- container_16 -->

If I have home as segment_1, it shows the title template with the embed title=welcome.

Is there a better way to do this?

  • 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-01T04:13:29+00:00Added an answer on June 1, 2026 at 4:13 am

    Can you not use {logged_in} and {logged_out} variables?

    Either way add additional conditionals:

    {if "{segment_1}" == "home"}
      {embed="include/title" title="welcome"}
    {if:elseif "{segment_1}" == "login" && logged_out}
      {embed="include/title" title="login"}
    {if:else}
      {if logged_in}
        {embed="include/title" title="welcome"}
      {if:else}
        {embed="include/title" title="login"}
      {/if}
    {/if}
    

    In older versions of EE I’ve had issues with the if:else not working on the logged_in conditional, so you may just need to replace with:

    {if logged_in}
    {/if}
    {if logged_out}
    {/if}
    

    If you have to use your session variable, ensure PHP is turned on in the template, and parsing is set to before EE. And you’d need to change the conditional slightly:

    {if:elseif "{segment_1}" == "login" && "0" == "<?= (isset($_SESSION['loggedin'])) ? "1" : "0"; ?>"}
    

    Although you might be able to get away with this (you’d need to test to confirm):

    ... && <?= (isset($_SESSION['loggedin'])) ? true : false; ?>}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is this possible to do the following in ExpressionEngine: (code taken from here )
How to make a counter in ExpressionEngine? {exp:weblog:entries weblog=news limit=15} {title} {body} Posted on
I am posting a form in an expressionengine (1.6.8) template. I'm doing it using
How do we sort using the database class in expressionengine. orderby and sort are
Is there a way of disabling the {title} tag in ExpressionEngine 2? My client
In an ExpressionEngine template, I'm setting a PHP session variable in a javascript file
I have an expressionengine template for frontend users using safecracker to create entries. ex:
We use the ExpressionEngine CMS (php) to create websites. For each site, we set
I'm using expressionengine as a CMS but want to override the core validation for
I am using ExpressionEngine 2.2.1 and am trying to create a conditional that will

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.