PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 19th, 2000, 12:03 AM
tennisguy tennisguy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Location: Cleveland
Posts: 16 tennisguy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hello. I am building a "custom links" feature on a web site. Currently, I am storing the url in a cookie and the name of the web site in another cookie. Having 10 custom links would mean 20 cookies. However, in the specifications of cookies (Netscape), there is a maximum limit of 20 on the number of cookies per domain. My question is: I know of a site at
http://www.hammervald.se/search-this/

which got around the problem by using a BIG cookie with all the information separated by a delimiter such as %. Would would be the code to parse this string in the cookie?

Suppose the contents of my cookie is:
CookieName = "URL1%site1.com%NAME1%site#1%URL2%site2.com%NAME2%site#2%URL3%site3.comNAME3%site#3..." How would I parse this string to get the following variables?

$URL1 = "site1.com"
$NAME1 = "site#1"... etc

Also, what would be a good delimiter to use? Is % very compatible?

Thank you for your help and I am very hungry for some more cookies

Reply With Quote
  #2  
Old February 19th, 2000, 06:03 AM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 17
Send a message via AIM to rod k
Check out explode() and split() in the manual. As for a delimiter I wouldn't use % as that's used in url coding to delimit an encoded character. Pipe's (|) are good, usually.

However, you might want to use serialize()/unserialize() as an alternative. Store everything in a 2d array ($site[0][name], $site[0][url], etc) then $mycookie=serialize($site) and put $mycookie in the cookie. When you remove it just $site=unserialize($mycookie). Then you have no limits on cookies and only have to store one.

Reply With Quote
  #3  
Old February 19th, 2000, 05:47 PM
tennisguy tennisguy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Location: Cleveland
Posts: 16 tennisguy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for the answer. However, I am confused about 2D arrays after reading the PHp documentation. I tried site[0][1] = $fav_name_1; but that did not work. So if I have the following variables stored already: $fav_path_1, $fav_name_1, $fav_path_2 and $fav_name_2, what would be the code to create a 2D array and to serialize/unserialize it? Should I worry about urlencoding the string? What about each() and list()? Should I care about them? Sorry about being such a newbie but any help would be greatly appreciated.

Reply With Quote
  #4  
Old February 19th, 2000, 06:06 PM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 17
Send a message via AIM to rod k
You forgot the $ before site[0][1].

After you have your array set up you can do this:

$data=serialize($site);
Then you can setcookie with $data.

After you read the cookie do:
$site=unserialize($data);

I don't use cookies much, but I don't think you need to urlencode them. Try it and find out.

each and list can be used, if you want or you can just use the array. Up to you.

Reply With Quote
  #5  
Old February 20th, 2000, 02:52 AM
tennisguy tennisguy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Location: Cleveland
Posts: 16 tennisguy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thank you!

Reply With Quote
  #6  
Old February 23rd, 2000, 10:07 AM
kgeffert kgeffert is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Posts: 2 kgeffert User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
If I needed to track that much information about a user I'd probably store the urls and such in a database. That way you need only to store one or two cookies such as a username and session id. Which would relate directly back to the information in the DB.

This would give you great flexibility and allow you to store as many links as the user wants.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Only 20 Cookies??? - Please give me more cookies!

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap