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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:53:14+00:00 2026-05-11T06:53:14+00:00

I am creating a user login system similar to a client intranat. And when

  • 0

I am creating a user login system similar to a client intranat. And when I try to access the main page I get a redirect loop in FF.

I am checking to see if a user is logged in with this:

if(($_SERVER['PHP_SELF'] != '/webmaster/index.php') && ($_SESSION['loggedin'] != '1234')){   header('Location: '.$domain.'index.php?l=no');   exit(); } 

Below is my process-login.php -> which is the file that handles client login:

<?php ob_start(); session_start(); ini_set('display_errors', 1); error_reporting(E_ALL | E_NOTICE); include ('config.inc.php'); include ('jsonEncode.php');  // username and password sent from form $username = ''; $password = ''; $username = mysql_real_escape_string($_GET['username']); $password = mysql_real_escape_string($_GET['password']);  $sql    = 'SELECT * FROM clients WHERE username='$username' AND password='$password' LIMIT 1'; //echo $sql; $result = mysql_query($sql);  $data   = mysql_fetch_array($result); $count  = mysql_num_rows($result);  if($count==1){     $_SESSION['username']  = $username;     $_SESSION['password']  = $password;     $_SESSION['client_id'] = $data['c_id'];     $_SESSION['loggedin']  = '1234';      /*     echo $_SESSION['client_id'];     echo $_SESSION['password'];     echo $_SESSION['username'];     */     echo $_SESSION['loggedin'];     // valid     $var = array('valid' => 1, 'username' => $username, 'password' => $password);     print php_json_encode($var);  }else{     // invalid     $var = array('valid' => 0, 'username' => $username, 'password' => $password);     print php_json_encode($var); } ?> 

The main index.php page has two forms one for clients and one for webmastsers, and if you are a client you are redirected to: clients/, and if you’re a webmaster you’re redirected to: webmaster/.

I have checked my login scripts and it is returning the right information and logging it in, but it keeps looping.

The form is submitted via ajax then returns JSON with a value of 1 being valid or 0 invalid to see if the user can continue.

  • 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. 2026-05-11T06:53:14+00:00Added an answer on May 11, 2026 at 6:53 am

    If the form is submitted through AJAX are you sure that the session cookie is set accordingly? I know that Firefox will send cookie information together with asynchronous requests but are you confident that it will work the other way around?

    if (($_SERVER['PHP_SELF'] != '/webmaster/index.php') &&      ($_SESSION['loggedin'] != '1234')) { // I don't like this!     header('Location: '.$domain.'index.php?l=no');     exit(); } 

    The $_SESSION[‘loggedin’] value would be != ‘1234’ most of the time and this would be the case initially, you should check whether the value is undefined as well and act accordingly. What guarantees do you have right now that if the user requests index.php that $_SESSION[‘loggedin’] is not != ‘1234’ if this is a new session? Otherwise you’ll have a redirection loop which can be caused if the AJAX response doesn’t set a session cookie accordingly, assuming you use session cookies to track user session?

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

Sidebar

Related Questions

Has anyone created or read an article on creating a multi-factor login system for
I am creating a login system for a web application using PHP. My question
I'm creating a login system in PHP, and I want to know how to
I am creating a custom CMS and have built a login system and was
I am creating a java application and I need to get the user PINs
I'm creating an application similar to phpmyadmin (database management UI). The user needs to
I am creating a login page for my web application. I want to create
I'm creating a control and need to pass it the current logon user as
When creating scrollable user controls with .NET and WinForms I have repeatedly encountered situations
When I'm creating a user for my web application, an SMTP email (using ASP.NET's

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.