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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:47:54+00:00 2026-06-01T12:47:54+00:00

I am working on a login system for a client and I have run

  • 0

I am working on a login system for a client and I have run into an issue that I am unsure how to fix. I have it set so that when the user tries to access the index.php of a certain directory they are require to login. The code that I have doing this is:

<?php
   session_start();
   if(!$_SESSION['myusername']){
      header("location:Login_admin.php");
   }
?>

On the Login_admin.php page, there is a form with the action=”checklogin.php”. here is where it connects to the database and starts a session where it stores the username:

if($count==1){
   session_start();
   // Register $myusername, $mypassword and redirect to file "login_success.php"
   $_SESSION['myusername'];
   $_SESSION['mypassword']; 
   header("location:index.php");
}

Originally the above code did not have the session_start() so I added that in in attempt to solve my problem.

The actual problem is the session is not registering. If I go to one of the other pages in the director (all of them have that first segment of code at teh top) and log in it sends me to index.php like I want, but when I try to go back to that page it makes me log in again. At one point I had that first segment of code on my index page and even with the correct log in it would loop back to the login page.

I was shown this script by a friend and have not really changed much. Originally the script had:

session_register("myusername");

But after some debugging, I changed it to:

$_SESSION['myusername'];

A final note, I am not an expert the issue is probably considered a silly mistake but for the life of me I can’t figure it out.

Thanks in advance!

  • 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-01T12:47:55+00:00Added an answer on June 1, 2026 at 12:47 pm

    the

    $_SESSION['myusername'];
    

    line does absolutely nothing
    to assign a value to session variable you have to assign a value to session variable
    the usual way values being assigned to variables in PHP

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

Sidebar

Related Questions

I'm using PHP 4.3.9, Apache/2.0.52 I'm trying to get a login system working that
I am working on a relatively simple login system for Symfony2. I have the
I am working on a php/mysql login system for a webproject. After looking through
While writing a login system for a web project Im working on I came
I'm working on a login page, I want the user to see his name
I've created an almost full working login system, but my registration page doesn't work
Coding Platform ASP.NET 4.0 WebForms I have two pages that are relevant here Login.aspx
I have written a windows service that uses the openpop mail client and retreives
I am working on a small project where a client would like to have
I just finished working on a webapp of mine that will have lots of

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.