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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:29:44+00:00 2026-05-15T22:29:44+00:00

I have this php login system, I had it working great on localhost, I

  • 0

I have this php login system, I had it working great on localhost, I bought a webhotel and now it doesn’t work no longer, and i can’t find where it goes wrong.

I get no errors.

The login page is in index.php, and when you sign in, and if everythings ok (no errors/wrong pw etc.) then you will be redirected to home.php.

This is not the case. When I log in, it just refreshes the index.php and outputs this at top:

Warning: Cannot modify header information – headers already sent by (httpd.www/oBz/index.php:2) in httpd.www/oBz/index.php on line 221

on line 221 there’s:
header(“Location: home.php”);

ok, so i went to home.php manually by enter in the address. Now in home.php I have this at top:

include 'dbc.php';
page_protect();
echo "HELLO WORLD";

page_protect checks if there’s any sessions set or cookie(remember me), but if something has been set you will see the content “HELLO WORLD” else you wont.

But right now when i enter home.php I just receive this:

Warning: session_start() [function.session-start]: Cannot send session cookie – headers already sent by (output started at httpd.www/oBz/dbc.php:29) in httpd.www/oBz/dbc.php on line 69
Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at httpd.www/oBz/dbc.php:29) in httpd.www/oBz/dbc.php on line 69
Warning: Cannot modify header information – headers already sent by (output started at httpd.www/oBz/dbc.php:29) in httpd.www/oBz/dbc.php on line 117

Line 69 theres session_start(), and it’s the first line in the function page_protect();

line 117 theres header("Location: index.php") and is there to redirect if you are not logged in(session set/cookie set)

Hope i provided information enough, if not just comment what you need, and i’ll try my best to provide it to you..

Thank you

Update:

Here is dbc.php: http://phpbin.net/x/999009567

**index.php where you log in and where the session sets http://phpbin.net/x/1564167411

**UPDATE:
I now solved the header warning/errors but that was not the solution for the session issue!

**UPDATE:
phpbin.net/x/25857430 the updated dbc.php, all the html that was in the dbc.php previously is in a new file top.php. I include the top.php file AFTER the doLogin function section in index.php, so there doesnt get any errors with the headers..

***UPDATE: The problem is somewhere here: http://phpbin.net/x/557713701 thats why its redirecting me to index.php all the time

  • 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-15T22:29:44+00:00Added an answer on May 15, 2026 at 10:29 pm

    You’ve already sent output to the browser with all that HTML that exists before your first bit of PHP.

    You need to rearrange the code, so that anything which needs to send headers happens before any HTML is sent to the browser.

    So:

    <?php
    session_start();
    
    ?>
    <html>
    <head>
    ...
    

    The simplest answer may be to move all of that HTML after the PHP code. There’s a session_regenerate_id() call in there and another session_start() in the logout function.

    For that matter, why do have any HTML in this file anyway? Beyond the session functions, I spotted at least 2 header() calls.

    Update:

    if(isset($_COOKIE['user_id']) && isset($_COOKIE['user_key'])){
        /* we double check cookie expiry time against stored in database */
    
    // I snipped a bunch of code, to point out what's going on here
    
      } else {
        header("Location: index.php");
        die();
        }
    

    So, if the cookie values don’t exist, what do you suppose happens here?

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

Sidebar

Related Questions

So I created this little login system for my php site, I have a
I have this code for displaying content for login and registration in my PHP
I have a PHP login / logout system. The code for the logout is
I was reading this tutorial for a simple PHP login system . In the
I am making a registration/login system with php. I think I have all the
My problem in fairly simple. I have a login system constructed using php, mysql
I have a facebook login system that seems to work fine, but I want
I have this PHP code to highlight the Query on search results. if (isset($_REQUEST['k'])){
I have this PHP page where the user can select and un-select items. The
I have this PHP script which i'm grabbing images from a directory and displaying

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.