Jump to content

"Solved" Cookie


imartin123

Recommended Posts

I am new to PHP. Need Help.

I have set cookie and I can use the in all my scripts except 1.

When I try to use it in this one script it is blank but I can still see it
in all other scripts.

Can anyone help me with this.

Also I will be happy to make a donation the cause in the next few days.

Thanks

Ike
Link to comment
https://forums.phpfreaks.com/topic/23398-solved-cookie/
Share on other sites

In testing when I try to move my cookie to another var
it comes up blank.

Also when I change this test to echo other vars
I get the same info. It don't show a new echos.

Thanks for any help.

Ikw


<?php
echo $Var;

$Mycookie = $_Cookie['Testvar'];
echo $Mycookie;
echo "Here Test";

echo "IKE";
echo $Var;

?>
Link to comment
https://forums.phpfreaks.com/topic/23398-solved-cookie/#findComment-106473
Share on other sites

You first have to start a session in order to pass variables without $_GET,$_POST
so this is your first file:
1.
<?php
session_start();
$_SESSION[var]='string';
?>
this is the second file that will use it
2.
<?php
session_start();
$var=$_SESSION[var];
echo $var;
?>

the second file will echo your string. You can also use session_destroy when you don't need to use your cookies anymore (they will still be available for that page, to deal with this problem check unset)
Link to comment
https://forums.phpfreaks.com/topic/23398-solved-cookie/#findComment-106483
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.