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

  • Home
  • SEARCH
  • 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 3633828
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:42:08+00:00 2026-05-19T00:42:08+00:00

Greetings, Been going around in circles trying to figure out why this will not

  • 0

Greetings,

Been going around in circles trying to figure out why this will not work. Making a low security log-in system using cookies due to an issue with sessions on the device being used. The set cookie works on its own but either is not setting properly in this script or is not being read properly on the auth script. Also, after the cookie should be set, it is not in the browser. Ideas??

Login

   <?php
    //If passwords match, a cookie is created
    if ($pw = $hashedpw) {
         $memberID = "1221"; //Pulled from DB
         setcookie('MDADMIN_SESS_ID',$memberID,'0','', '.somewhere.com');
        header('Location: http://somewhere.com/secure_page.php');
    }
    ?>

Auth

<?php
//Verify that cookie is present
$cookie = $_COOKIE['MDADMIN_SESS_ID'];
if(!isset($cookie)) {
        header("Location: http://somewhere.com/failed.php");
        exit();
}
?>

The process is as follows: Login Form -> Login Script -> Secure Page (if passwords match) -> Auth Script checked (via include) -> redirect to failed login if cookie not present. When run, it always defaults to the cookie not being present, even though the login script correctly directs to the secure page (logged in successfully).

  • 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-19T00:42:09+00:00Added an answer on May 19, 2026 at 12:42 am

    try

    <?php
    //If passwords match, a cookie is created
        if ($pw = $hashedpw) {
            $memberID = "1221"; //Pulled from DB
            setcookie('MDADMIN_SESS_ID',$memberID,'0','/', '.somewhere.com');
            header('Location: http://somewhere.com/secure_page.php');
            exit();
        }
    ?>
    

    You are missing a / for the path.

    Also make sure you have an exit(); function after the header; because if you unset the cookie later at someplace then it might also get affect.

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

Sidebar

Related Questions

I've been scratching my head as to why this code will work some of
Greetings everyone and thank you for checking out my post. I am trying to
I have been trying to figure the following for a couple days. Please HELP
Greetings, I've been working out of an embedded version of Java where the height
Greetings! I've been fooling around (a bit) with C# and its assemblies. And so
Greetings! I've been trying to display some HTML with Java using JEditorPane . But
Greetings, I've been with this about 1 or 2 hours and it seems I
Greetings, I've been scanning the internet on how to do this, but so far
Greetings all, I realize this issue has been posed before in other forms, and
Greetings. I've been using vim for years, and I've recently started toying with XCode.

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.