Jump to content

Recommended Posts

Your browser may need to refresh after the cookie is disabled.  Try closing down the browser and re-opening it.

 

I do something like this:

<?php
session_start();
setcookie('value', $value, time() + 3600, "/");
echo $_COOKIE['value'];
?>

 

to delete I use:

<?php
session_start();
setcookie('value', '', time() - 3600, "/");
?>

Link to comment
https://forums.phpfreaks.com/topic/102784-cookies/#findComment-526487
Share on other sites

sorry if I didn't explain it better....

 

I set the cookie in the body of the code and/or delete it there as well.

 

<html>
<head></head>
<body>
<?php
# start session
session_start();
# create cookie
setcookie('value', $value, time() + 3600, "/");
# display cookie; after page has been refreshed
echo $_COOKIE["value"];

# deleting cookies
setcookie('value', "", time() - 3600, "/");

?>
</body>
</html>

 

if anyone notices and error feel free to let us know, I use this method and it works for me...

Link to comment
https://forums.phpfreaks.com/topic/102784-cookies/#findComment-526505
Share on other sites

<html>

<head></head>

<body>

<?php

# start session

session_start();

# create cookie

setcookie('value', $value, time() + 3600, "/");

 

$_COOKIE['value']=$value;  <-----------------------------------------------------is this valid, or do I use the function again?

 

# display cookie; after page has been refreshed

echo $_COOKIE["value"];

 

# deleting cookies

setcookie('value', "", time() - 3600, "/");

 

?>

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/102784-cookies/#findComment-526513
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.