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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:39:05+00:00 2026-06-01T03:39:05+00:00

so I made a simple user log in website, and I want to set

  • 0

so I made a simple user log in website, and I want to set a cookie so that when they come back to the website, it will take them to the members area and not the main page, kind of like a “remember me” function that redirects users to a members area if a cookie is set.

Problem I am facing: The php code right before the html code does not redirect to the member.php page even though the cookie is set!

Note: I’m just using parts of the code, and not the entire code/ other files to simplify the question.

here’s my code:

main.php (this is the main page, and also where the log-in form is, but log in form is not shown)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<?php 
     //Checks if there is a login cookie
     if(isset($_COOKIE["blablabla"]))  //if cookie is set
     {  
        header("Location: www.website.com/member.php"); //redirect to member.php
     }
    else
    {
        //otherwise, redirect to nocookiefound.php
        header("Location: www.website.com/nocookiefound.php"); 
    }
?>
<html>
    <body>
        <?php
            echo "Welcome " . $_COOKIE["blablabla"] . "!<br />";
            //I ran a echo test to see if cookie is still there, and it is.
        ?>
    </body>
</html>

So my question is, can my redirect work the way it is?

I must be doing something wrong because it’s not redirecting to member.php even though the cookie echos the correct value.

So, if i was originally in the members.php page after I logged in, then go back to main.php, it SHOULD redirect me to members.php, but it doesn’t, it just stays at main.php. Anyone know what’s going on? I would appreciate all the help I can get. Thanks

  • 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-01T03:39:06+00:00Added an answer on June 1, 2026 at 3:39 am

    As well as what @Dogbert says, your redirection is invalid. Try:

    header("Location: http://www.website.com/member.php");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made a simple program that allows the user to pick a number of
I've made simple nodejs application by using nodejs+express. Now I want to make user
I've created a simple webapp with user authentication. I've made two models: Users for
We made a simple application and using GoogleAppEngineLauncher (GAEL) ran that locally. Then we
I made this simple function to filter the data. I add the symbols that
I recently made a simple game where user can submit his/her high scores online.
I've made a simple project to illustrate my problem. I have a user control
I've made a simple app, where I have a list of songs. The user
I made a simple login form where a user can click on a register
Today we faced a quite simple problem that were made even simpler by 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.