Jump to bottom

Closed Thread Icon

Topic awaiting preservation: php styleswitcher... (Page 2 of 2) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12021" title="Pages that link to Topic awaiting preservation: php styleswitcher... (Page 2 of 2)" rel="nofollow" >Topic awaiting preservation: php styleswitcher... <span class="small">(Page 2 of 2)</span>\

 
Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 03-20-2002 14:53

Oh INI, sure - tease the poor new guy!

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 03-20-2002 15:21

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 03-20-2002 16:12

Nah - I'm just messin' with ya....

bitdamaged
Maniac (V) Mad Scientist

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

posted posted 03-20-2002 17:35

Hmm I seem to recall Ini posting something about cookie-less cookies somewhere.

Let's see how's that search functions working today....

Of course you could just set one cookie, that being a unique user id and store the rest of the data in your db. which may be the easiet and best way to do things it gets around most cookie limitations.



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

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 03-20-2002 18:35

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

deethree
Obsessive-Compulsive (I) Inmate

From: An igloo up north
Insane since: Mar 2002

posted posted 03-20-2002 20:12

Hmm you guys mean if a user chooses a blue theme + something else a cookie would be made that = 12 (for example.)

Thats an interesting concept.

deethree
Obsessive-Compulsive (I) Inmate

From: An igloo up north
Insane since: Mar 2002

posted posted 03-21-2002 22:35

Well I must thank everyone.. I figured it out last night and set up my test site with cookies... I'd like to work it the way Pugzly had his site with the site just being updated without going to another page... but all in due time.... I'll be looking over this thread for the explode() info and probably using that as well...

I guess I can answer any (basic)questions posted on the topic from here on in seeing as I got it working (finally)

A big Thanks to everyone

d3

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 03-21-2002 23:49

Good deal!

deethree
Obsessive-Compulsive (I) Inmate

From: An igloo up north
Insane since: Mar 2002

posted posted 03-22-2002 21:59

/me smacks his head.

now I get it... *duh*

I read this 9 times before it sunk in:

foreach ($temp as $var) {
$t = explode("=", $var);
$cookies[$t[0]] = $t[1];

Noooow I understand... whew...

So to ask the next question... if I only wanted one value from the deal... I'd just call $cookies[$t[0]] or [1]] right?

bitdamaged
Maniac (V) Mad Scientist

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

posted posted 03-22-2002 22:58

Hmm... not sure what you mean by "one value"

I'd keep the code as is, the way it's written it will deal with any amount of key value pairs you set in your cookie (even just one)
You should never reference the cookies array like this
$cookie[$t[0]] those $t values are just temporary in the foreach loop that get changed each time around. If you call something like that after the foreach it will just be the last value you used.

let's put it this way. you have a set a cookie that looks like this

'color=blue'

After that code runs you have a variable called
$cookie['color'] // <-- (that's how you refrence it)

And it's value is "blue"

So your code could look like this

echo "Hi I am mike, my favorite color is $cookie['color']";

The cool thing about this is you can put tons of little chunks of data into that one cookie

name=mike&color=blue&music=rock&pet=dog

Would end up like so
echo "Hi my name is $cookie['name'] my favorite color is $cookie['color'] my favorite kind of music is $cookie['music'] and I have a pet $cookie['pet']";

All this is done without having to touch that code. (feel free to touch it though!)




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

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 03-22-2002 23:33

BD - You are awesome.

<salesman>
Now just whip this up into a tutorial and post it at GurusNetwork....
</salesman>

bitdamaged
Maniac (V) Mad Scientist

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

posted posted 03-23-2002 03:08

Oh wish I had the time I got screwed on a project and I'm doing 14 hour days right now. Email me in a week or so and I'll try to whip something up.



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

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 03-23-2002 04:36

14 hour days?!

Aren't you the owner of that place yet? BitdamagedTV?

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 07-18-2002 19:03

Okay, I'm a bit stuck on this. Using Bitdamaged's code.....

code:
<?php
$value = "lan=eng&col=red&name=Cornholio";
setcookie("style", $value,time()+3600);
echo("<script>location.href=\"http://development.runningwolf.com/code/php/themes/new/getcookie.php\"</script>");
?>


"getcookie.php"

code:
<?php
$temp = explode("&", $HTTP_COOKIE_VARS['style']);
$cookies = array();
foreach ($temp as $var) {
$t = explode("=", $var);
$cookies[$t[0]] = $t[1];
}

foreach($cookies as $key => $value) {
echo "You have set $key as $value <br /><br /><br />":
}?>



This works fine. Now, I'm trying to get a single value, using the suggested method. When I ad
print "Color: $cookies['col']";

I get
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in getcookie.php on line 13

line 13 is the print statement.

I am really getting lost with this! What simple little thing did I miss?




[This message has been edited by Pugzly (edited 07-18-2002).]

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 07-18-2002 19:14

Your syntax is wrong. You should write print statement like this:

print "Color: " . $cookies['col'];


Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 07-18-2002 19:35

Aha!

Ok. Well, I usually understand the concepts - just the syntax kills me.

Thanks!

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 07-18-2002 20:19

Okay, so this of course prompts another question.....

Let's say I have my $value = "first=bob&last=smith&dob=01/01/1980&hair=black&eyes=blue"

That gets stored in the cookie. No problem. I can get that info from the cookie - no problem. Now what if I want to change just ONE thing. Do I need to explode thing apart, change the variable, combine them back, and then rewrite the cookie variable? Or should I just do a preg_replace for the info?

bitdamaged
Maniac (V) Mad Scientist

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

posted posted 07-18-2002 20:27

You'd have to explode it and implode it back.

I'd write up a little class or function to automate the process.



.:[ Never resist a perfect moment ]:.

« Previous Page1 [2]

« BackwardsOnwards »

Show Forum Drop Down Menu