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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:00:02+00:00 2026-06-06T01:00:02+00:00

Maybe im missing something but im not sure. All im simply trying to do

  • 0

Maybe im missing something but im not sure. All im simply trying to do is set cookies so i can retrieve their value later. Im trying to implement such a thing but to no avail….not sure why its not working since its not that difficult.

  1. i have a simple log in form you know, username/pass etc…nothing fancy.

  2. On successful login, i have something like this:

    //COOKIE DETAILS HERE

    setcookie('username4pc',$userName);
    setcookie('userpass4pc',$userPass);
    
    header("Location:testCookie.php");
    

And ive made sure this is going before the HTML tag and before anything is outputted to the page.
So much so that, ive taken out the above from my program that im working on and put it on a blank html page to test, and it now looks like this…

after clicking on “login” on the indexpage, it goes to my new test page which only has this:

<?php
setcookie('username4pc',$userName);
setcookie('userpass4pc',$userPass);
header("Location:testCookie.php");
?>
<html></html>

and after the above runs, the header throws it to testCookie.php page which only has this

<?php
//test cookie

if(isset($_COOKIE['first_name'])){
    echo " cookies set";

} else {
    echo "cookie not set";  
} 
?>
<html></html>

and no matter what i do, i always get the “cookie not set”

Any ideas as to why and whats going wrong?

  • 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-06T01:00:05+00:00Added an answer on June 6, 2026 at 1:00 am

    You’re accessing the cookie wrong, it should be:

    if(isset($_COOKIE['username4pc'])){
    or
    if(isset($_COOKIE['userpass4pc'])){
    

    a simple var_dump($_COOKIE) will show you exactly what’s in the cookie array.

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

Sidebar

Related Questions

Maybe I'm just missing something in the docs, but it seem it's not possible
Maybe I'm missing something obvious, but I how can I view the expression tree
Maybe I'm missing something, but from Apple's documentation for NSHTTPCookieStorage , I can't help
I am not sure if I am missing something, but for the life of
Maybe I am missing something, but they seem similar. If you use for example...
Maybe I am missing something, but in symfony examples, in form submission action there's
I'm not sure if I'm missing something. If Aptana is entirely based on Eclipse,
Maybe I am missing something simple here, but it is frustrating me. So what
I may be missing something obvious here, but how could I rewrite this code
Maybe I'm missing it somewhere in the PHP manual, but what exactly is 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.