0

Identify the error in the following code php

<?php $value = "John"; <b> setcookie ("user", $value, time() + (86400 * 30), "/") </b> ; if(isset($_COOKIE['user'])) { echo "Value is: ".$_COOKIE['user']; } //Outputs "Value is: John" ?>

21st Jan 2017, 9:17 AM
Rabah Bouzar
Rabah Bouzar - avatar
5 Answers
0
remove <b> and </b>
21st Jan 2017, 11:18 AM
Jonas Geiler
Jonas Geiler - avatar
0
i did it no answer too
21st Jan 2017, 11:19 AM
Rabah Bouzar
Rabah Bouzar - avatar
0
?
21st Jan 2017, 11:19 AM
Jonas Geiler
Jonas Geiler - avatar
0
Warning: Cannot modify header information - headers already sent by (output started at ..\Playground\:1) in ..\Playground\ PHP Warning: Cannot modify header information - headers already sent by (output started at ..\Playground\:1) in ..\Playground\. the following mssage displayed
21st Jan 2017, 11:21 AM
Rabah Bouzar
Rabah Bouzar - avatar
0
Okay I tried it and it looks like you cannot use Cookies in sololearn. To use setcookie, make sure no headers are sent before (No HTML before, no echo before, no include before).
21st Jan 2017, 11:27 AM
Jonas Geiler
Jonas Geiler - avatar