[PHP-DB] setcookie

2003-09-05 Thread Ohlson Stefan
Hi!
(I'm using php3 on an apache-server)

I'm doing lika a shoppingcart where the user can put items.
By some reason, when I use setcookie, I can only save between 14-17 posts.

Example: 
 setcookie(items, item1);
 setcookie(items, item2);
 ...
 setcookie(items, item17);

After this it will not save any more items.
It seems to get full..?

NE1 had experience with this?
Or if you have a different and better way to store many 
items on the server for a user they are most welcome!

Thanx!
//Stefan

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] setcookie

2003-09-05 Thread Hutchins, Richard
Stefan,

OK, there may be more to this (and I'm sure others will respond if there
is), but here's my best take on your problem.

You're using the PHP function setcookie() which sets a cookie in the remote
browser, not on the server (check Chapter 19 in the PHP manual for a quick
explanation or read Netscape's cookie spec for ALL of the details). What the
PHP manual doesn't say about the cookie spec is that remote browsers only
allow any given server to set a maximum of 20 cookies on a user's machine.
So, if you're setting any other cookies in your shopping cart application in
addition to the items cookie you listed below, you may be hitting that
limit of 20.

If you wish to assign multiple values to a cookie, chapter 19 of the PHP
manual states the following:

If you wish to assign multiple values to a single cookie, just add [] to
the cookie name. 

So if you wanted to set one cookie to hold all of your items, you should be
able to setcookie(items[], item1), setcookie(items[], item2), etc up to
itemN. Then you can access the items as an array in a PHP script. I'm pretty
sure that handling your list of items in this manner would allow you to
store a large number of items in the same cookie without setting additional
cookies and running into the upper limit of 20. I haven't ever tried it this
way before so I may be totally wrong here. I've never done a shopping cart
application before and usually only set a cookie or two for last visit date,
last page visited, that kind of stuff.

Like I said, this is my best guess as to what your problem may be. Hope it
helps.

Rich

 -Original Message-
 From: Ohlson Stefan [mailto:[EMAIL PROTECTED]
 Sent: Friday, September 05, 2003 8:33 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] setcookie
 
 
 Hi!
 (I'm using php3 on an apache-server)
 
 I'm doing lika a shoppingcart where the user can put items.
 By some reason, when I use setcookie, I can only save between 
 14-17 posts.
 
 Example: 
  setcookie(items, item1);
  setcookie(items, item2);
  ...
  setcookie(items, item17);
 
 After this it will not save any more items.
 It seems to get full..?
 
 NE1 had experience with this?
 Or if you have a different and better way to store many 
 items on the server for a user they are most welcome!
 
 Thanx!
 //Stefan
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] setcookie

2003-09-05 Thread Parker Morse
On Friday, Sep 5, 2003, at 08:58 US/Eastern, Hutchins, Richard wrote:
If you wish to assign multiple values to a single cookie, just add [] 
to
the cookie name. 

So if you wanted to set one cookie to hold all of your items, you 
should be
able to setcookie(items[], item1), setcookie(items[], item2), etc 
up to
itemN. Then you can access the items as an array in a PHP script. I'm 
pretty
sure that handling your list of items in this manner would allow you to
store a large number of items in the same cookie without setting 
additional
cookies and running into the upper limit of 20.
IIRC there is a browser-set limit to the size of a given cookie, around 
4k. That's pretty big, but there is a limit and it may vary by browser, 
so it's to your advantage to keep it short.

pjm

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] setcookie warning?

2002-05-23 Thread Dave Carrera

I get this warning with setcookie

Warning: setcookie() expects parameter 3 to be long, string given

But the cookie works ok

this is the line setting the cookie

setcookie(selarea,$gotarea,/ );

any ideas

i am using php 4.2

Thanks in advance
Dave C


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php