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