February 08, 2012, 10:20:27 PM
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
: follow us on twitter @dotdragnet
Home
Help
Search
Login
Register
DotDragnet
>
The Tech Side
>
Tech stuff
>
cookies and not the chocolate ones
Pages: [
1
]
Go Down
« previous
next »
Print
Author
Topic: cookies and not the chocolate ones (Read 750 times)
SLEE
Hero Member
Posts: 816
cookies and not the chocolate ones
«
on:
February 27, 2010, 07:06:19 PM »
right im dabbling with some php and I need to store some values in a cookie.
i will need to set 5 sets of values with 4 values for each set.
what is the best way to store them in a cookie?
should i set a different cookie for each set?
is there a limit to the amount of data you can store in a cookie?
Logged
SLEE - still the most confusing ddner...
Follow me on Twitter
sarahA
DDN Contribs
Hero Member
Posts: 2123
Re: cookies and not the chocolate ones
«
Reply #1 on:
February 27, 2010, 09:08:31 PM »
Sounds like you want to use an array.
The limit on size is down to the browser. Couldn't say what the limit it. Easiest way is to test it yourself
Logged
Stuff By Me
:
Photos
SLEE
Hero Member
Posts: 816
Re: cookies and not the chocolate ones
«
Reply #2 on:
February 27, 2010, 09:41:51 PM »
thanks will do.
One further question, ive set up the cookie with one option for now to test it but when i click a link to activate it i need the page to refresh for it to work. i can use javascript but id rather not use that if i can.
Logged
SLEE - still the most confusing ddner...
Follow me on Twitter
JasonD
Global Moderator
Hero Member
Posts: 529
Re: cookies and not the chocolate ones
«
Reply #3 on:
February 28, 2010, 02:35:56 PM »
Cookies will be limited to the usable length of a http header (depends on server and browser, no limits are set by HTTP). All cookies share the same line, so one cookie or four cookies would make little difference.
This sort of thing is what sessions were made for.
Logged
SLEE
Hero Member
Posts: 816
Re: cookies and not the chocolate ones
«
Reply #4 on:
February 28, 2010, 10:24:46 PM »
thanks Jason I managed to sort it out, i used one cookie and stored only what was needed at the time in the cookie which i should of thought about in the first place. one thing I have noticed though is that setting a cookie and reading it immediately does not always work so i think i need to do as you say and use a session and use the cookie for when the user comes back.
Logged
SLEE - still the most confusing ddner...
Follow me on Twitter
JasonD
Global Moderator
Hero Member
Posts: 529
Re: cookies and not the chocolate ones
«
Reply #5 on:
February 28, 2010, 11:13:24 PM »
$_COOKIE is set from the request and not updated, but there is nothing stopping you from doing $_COOKIE['foo'] = 'bar' along with setcookie('foo', 'bar') if you feel the need.
Logged
SLEE
Hero Member
Posts: 816
Re: cookies and not the chocolate ones
«
Reply #6 on:
March 01, 2010, 01:14:04 PM »
Jason that was exactly what i needed! by using $_COOKIE['foo'] = 'bar' as well it works perfectly
Logged
SLEE - still the most confusing ddner...
Follow me on Twitter
Pages: [
1
]
Go Up
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General Category
-----------------------------
=> General Discussion
=> Jee's Forum of Appalling Jokes
-----------------------------
The Creative Side
-----------------------------
=> Arty stuff
=> Photography
=> On the web
-----------------------------
The Tech Side
-----------------------------
=> Tech stuff
=> Hardware & Software
-----------------------------
The Business Side
-----------------------------
=> Anything business related
-----------------------------
The Practical Side
-----------------------------
=> Practical Advice
DotDragnet
>
The Tech Side
>
Tech stuff
>
cookies and not the chocolate ones
Loading...