Jump to content

Cookies?


Vigilant Psyche

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.