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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:16:43+00:00 2026-06-13T17:16:43+00:00

PHP newbie here, I can’t understand what I’m doing wrong here. I’m trying to

  • 0

PHP newbie here, I can’t understand what I’m doing wrong here.
I’m trying to implement a cliché remember me function but I can’t get the cookies to work.
I’ve been at this for a good while.

All of this is wrapped in a password check function and I’m perfectly able to both login and echo my session. But I can’t seem to set my cookie. I’m using MAMP.

if($_POST['_remember'] == 'true') {
    $cookie = $_SESSION['user']['id']. '-' .$_SESSION['user']['password']. '-' .$_SESSION['user']['timestamp'];
    setcookie('remedy', $cookie, time() +60*60*24*7, '/', 'localhosttest');
  } else {
    //destroy any previously set cookie
    setcookie('remedy', '', time() -60*60*24*7, '/', 'localhosttest');
  }

echo $_COOKIE['remedy'];

I really wish there was something else I could give you, but this is all I have. I’m a graphics designer and a photographer, this kind of logic isn’t even near my ballpark. I apologise for the vague title, I’d fix it if I knew how to be more specific.

Also, my plan is to get the user ID, password (hashed and salted) and timestamp checked with the same values on the server. The timestamp value will be updated whenever the user browse the site. Is this good practice?

  • 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-13T17:16:44+00:00Added an answer on June 13, 2026 at 5:16 pm

    setcookie() prepares a cookie to be sent with the server response to the client. The $_COOKIE array is populated only when the Client sends a request.

    After you setcookie(), check the $_COOKIE array on the next page the user requests–you’ll see the cookie you created on the prior page request.

    Note the ‘on the next page load’ from the documentation (http://php.net/manual/en/function.setcookie.php):

    Once the cookies have been set, they can be accessed on the next page load with the $_COOKIE or $HTTP_COOKIE_VARS arrays. Note, superglobals such as $_COOKIE became available in PHP 4.1.0. Cookie values also exist in $_REQUEST.

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

Sidebar

Related Questions

Newbie here trying to maintain a PHP website for some charity organization, but cannot
Im sure this is simple but newbie here. I have 5 URLS cards.php&type=one cards.php&type=two
I'm a newbie to sql and am trying to follow this example here: http://net.tutsplus.com/tutorials/php/a-better-login-system/
Im a php/mySQL newbie and am trying to get the hang of it. I
I'm newbie with webapps and PHP. I'm trying to get a cookie that it's
I'm a newbie programmer doing his best to self learn PHP. I'm trying to
Newbie question here, is there any inbuilt PHP tag that can be used to
Newbie here, trying to get this to work: I am making an online index
A really php newbie here, sorry if the question is too simple. I’m following
a bit of a PHP / MySQL newbie here... I've been building a PHP-based

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.