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

  • Home
  • SEARCH
  • 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 6551655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:21:51+00:00 2026-05-25T12:21:51+00:00

Here is my index.php <?php session_start(); if($_SESSION[‘authorizedreferral’] == false){ //login.php sets ‘authorizedreferral’ to false,

  • 0

Here is my index.php

<?php 
session_start();
if($_SESSION['authorizedreferral'] == false){       //login.php sets 'authorizedreferral' to false, and redirects to here. That way, login.php can't be accessed directly.
    session_destroy();                              //destroy the session, so the 'authorizedreferral' session is revaluated each time.
    echo "<h1>No ticky, no washy!</h1>";            //Sorry, don't pass go, and don't collect $200

}elseif(!isset($_COOKIE['loggedin'])){              //if there isn't a 'loggedin' cookie set, forward to the login.php page
    $_SESSION['authorizedreferral'] = true;         //yes, this is a correct referral. Otherwise, login.php will kick you out!
    header("Location: login.php");                  //forward to login.php
    exit;                                           //need this for some reason?
}

?>

Here is login.php:

<?php 
    session_start();                                            //start the session
    if(!isset($_SESSION['authorizedreferral'])){                //if 'authorizedreferral' isn't set (i.e. someone just loads login.php directly)

        $_SESSION['authorizedreferral'] = false;                //set 'authorizedreferral' to false - they aren't allowed here! 
        header('Location: http://'.$_SERVER["HTTP_HOST"]);      //and ship 'em back home!
        exit;                                                   //need this for some reason

    }


?>

Here are the possible situations:

  1. User goes to index.php – since they haven’t logged in (don’t have login cookie), they get sent to the login.php page to login.
  2. User tries to access login.php directly – they are sent back to the index.php, and get the message “No Ticky, no washy!”

However, right now, the user always receives “No Ticky, No Washy!” when accessing the index.php page. What am I missing?

See http://webify.nitrouscloud.net

  • 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-05-25T12:21:52+00:00Added an answer on May 25, 2026 at 12:21 pm

    The first time the user comes to the site, they’ll have an empty session. Your first if() clause will always evaluate to true, because of PHP’s typecasting rules:

    if($_SESSION['authorizedreferral'] == false)
    

    The session is empty, so there is no authorizedreferal value in the session, so PHP returns a ‘null’ (and an unset array key warning). Under PHP’s typecasting rules, null == false is TRUE.

    You’ll have to change your logic to check if a user’s logged in (do NOT store that in the cookie – store it in the session), and redirect to the login page:

    session_start();
    if (!isset($_SESSION['loggedin']) || ($_SESSION['loggedin'] === false)) {
        header("Location: login.php");
    }
    

    The other alternative is to use the strict comparison operator:

    if ($_SESSION['authorizedreferral'] !== true) {
        ...
    }
    

    which would only succeed if there really WAS an authorizedreferral value that was set to boolean true. You’d still get the unset array warning for brand new users, though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

You can see my project here - http://www.inluxphoto.com/custom/jsgallery/index.php I am attempting to make the
Index.php <?php session_start(); require_once('../inc/db/dbc.php'); include('login_helper.php'); ?> <!-- html form --> Login/Logout Links depending on
Here is my PHP code: <?php session_start(); if ( !isset($_SESSION['index_visited']) ) { $_SESSION['page2_visited'] =
I am trying to use Twitter Oauth to login. index.php <?php require (twitteroauth/twitteroauth.php); session_start();
Here is my try: @header(Content-type: text/html; charset=utf-8); @header(Location:/index.php); @header(Cache-Control: no-cache, must-revalidate); // HTTP/1.1 @header(Expires:
I have found some code on measuring execution time here http://www.dreamincode.net/forums/index.php?showtopic=24685 However, it does
Here's the XML file i'm working on: <list> <activity>swimming</activity> <activity>running</activity> <activity>soccer</activity> </list> The index.php,
i've a problem with php session handling that i can't explain to myself. I'm
Within my index.php file I have an AJAX function that will call a function
I'm wondering how I can make this code safer, I'm using it as login.php:

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.