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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:42:48+00:00 2026-06-03T13:42:48+00:00

I have set the session on all pages in my admin panel like so:

  • 0

I have set the session on all pages in my admin panel like so:

session_start();

if(!isset($_SESSION['username']))
   header("Location: login.php?e=please+login+first");

This seemed to be working properly on all my pages, but now when I refresh my page or click on a link, the page automatically redirects to login.php. This seems to happen infrequently. I don’t understand what is causing this problem

As an example, my menu bar is like:

home : doctors: hospitals:  feedback

If I am on hospitals.php, then after a few mins I click on feedback.php (or any other link) I get redirected to login.php. The next time if I again click on the link I will not get redirected

Here is my dologin.php code

$qry = "select * from admin where username='$uname' and password='$pwd'";
//echo $qry;exit;
$rs = mysql_query($qry,$con);
if($rec= mysql_fetch_array($rs))
{
  $_SESSION['username'] = $rec['username'];
    header("Location: index.php");
}
 else if (empty($uname))
{
     header("Location: login.php?e=Please+enter+username");
}
 else
 {
     header("Location: login.php?e=Invalid+username+or+password");
 }
  • 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-03T13:42:49+00:00Added an answer on June 3, 2026 at 1:42 pm

    EDIT:
    Replace your query:

    $qry = "select * from admin where username='$uname' and password='$pwd'";
    

    With this:

    $qry = "select * from admin where username='" . $uname . "' and password='" . $pwd . "'";
    

    Also replace your:

    session_start();
    

    with:

    if (!isset($_SESSION)) {
      session_start();
    }
    

    Recommendations: I would also recommend placing the content that is being reused from file to file in a PHP include such as header.php.

    PS: try accepting more answers, it helps motivate people to answer your questions. Also keeps the community alive.

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

Sidebar

Related Questions

I have problem with cakephp's Session->write method. If I set a value like $_SESSION['..']
I have secured pages that all check for a set session variable to determine
I have 2 pages: admin.php and admin_index.php. I have a username and password field
I am currently in C# and I have set Session variables on each page.
I have tried the obvious SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED, but my
I recently discovered that when you have a page set to session readonly and
I have set up multiple targets in a single xml file. I expect all
I have tried to set up a login page, but when I try to
I have the following in my BasePage class which all my ASPX pages derive
I am trying to set Session values using a IHttpModule. I have set the

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.