Jump to content

Archived

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

imartin123

"Solved" Cookie

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

Share this post


Link to post
Share on other sites
Please post the code for the page in question.. use the bbcode tags like this..

[nobbc]
[code]
<?php
//yourcode here
?>
[/code]
[/nobbc]

Tom

Share this post


Link to post
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;

?>

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

×

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.