Closed Thread Icon

Topic awaiting preservation: Got a cookie() ? (Page 1 of 1) Pages that link to <a href="http://ozoneasylum.com/backlink?for=12140" title="Pages that link to Topic awaiting preservation: Got a cookie() ? (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Got a cookie() ? <span class="small">(Page 1 of 1)</span>\

 
deethree
Obsessive-Compulsive (I) Inmate

From: An igloo up north
Insane since: Mar 2002

posted posted 03-25-2002 19:52

So I've been playing around with code from the themeswitch.php thread... and I had a few Q's to ask:

If you get cookie info like this: $var = $HTTP_COOKIE_VARS['var'];
What is $var 's value if the user is a first time user and doesn't have a cookie from my site...

-or-

Is there a way to check for the cookie first then run thru a few if's to see what action should be taken?

Trust me... more to follow.

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 03-25-2002 22:05

If you haven't written the cookie yet (which would include a value), then that variable would be empty.

deethree
Obsessive-Compulsive (I) Inmate

From: An igloo up north
Insane since: Mar 2002

posted posted 03-26-2002 03:17

So your saying $var would be " " right? Or are we talking null or 0 here?

deethree
Obsessive-Compulsive (I) Inmate

From: An igloo up north
Insane since: Mar 2002

posted posted 03-26-2002 04:50
code:
<?
$var = $HTTP_COOKIE_VARS['var'];
if ($var == ' ' && $var2 = ' ' ) { 01 }
elseif ($var2 != ' ') { 02 }
else { 03 }
?>



So... there's my 'code' (changed ever so slightly.. heh) When a person comes to my site... its checks for var in a cookie... If both var and var 2 are empty... 01 should trigger.

If var2 isn't empty.. (or ' ' as Pugzly said) 02 should trigger

and then 03 if we must..

I thought I RTFM'd enough.. and my VB background says thats all good... but it just doesn't work...

ohyeah... var2 comes from a form action=$PHP_self so as far as I know.. the $var2 should still be around.

/me looks for his dunce cap.

[This message has been edited by deethree (edited 03-26-2002).]

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 03-26-2002 17:29

Take a look at empty() function...

BTW String variable is empty only when it's equal to "" (there's no space).


deethree
Obsessive-Compulsive (I) Inmate

From: An igloo up north
Insane since: Mar 2002

posted posted 03-26-2002 21:09

First off Thanks mr.maX and who could forget Pugzly...

So I figured it out for the most part... the empty() was ok... but I still can't get this to trigger...

elseif ("$var" != " ") {
//elseif ("$var" != "") {
//elseif ("$var" != '') {
//elseif (!empty($var)) {
SetCookie("var",$var,time()+864000);
switch ($var){ }
}

That picks up the $var from the form which is located below V

The code that I've commented out are the past tries I've used... hasn't worked....

Basically... I don't know if my var is being carried over from the form when I press submit... I could do if $var = bleh but that would be messy and time consuming. *shrug*

Thanks again guys.


bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 03-26-2002 21:14

IF you want to quickly check your cookies you can just loop through the $HTTP_COOKIE_VARS array.


foreach ($HTTP_COOKIE_VARS as $key => $val) {
echo "Cookies!<br>"
echo "I have set the cookie named $key as \"$val\"<br>";
}






.:[ The Tao of Steve ]:.
Be Desireless
Be Excellent
Be Gone
...................................

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 03-27-2002 07:09

Deethree, it would be best to show us your complete code, because the problem is probably located somewhere else...


deethree
Obsessive-Compulsive (I) Inmate

From: An igloo up north
Insane since: Mar 2002

posted posted 03-28-2002 07:14

http://www.liquid2k.com/d3gfx/d3.txt

Semi commented...

Any help would be great.. thanks guys/gals (you never know. )

deethree
Obsessive-Compulsive (I) Inmate

From: An igloo up north
Insane since: Mar 2002

posted posted 03-28-2002 15:01

Interesting idea... would

empty($HTTP_COOKIE_VARS['theme'])

be a good idea?

« BackwardsOnwards »

Show Forum Drop Down Menu