Cookies and Arrays -- How to break apart cookies?
Posted: Tue Jul 29, 2008 11:32 am
Hey there guys.
I have been trying to figure out how this is to be done, but I am losing the battle here.
This is what I have coded so far:
------------------------------------------------------------------------------------------------
Page One: (User is logged out) -- Javascript page
* You add a "session"(s) to your profile.
* This "session"(s) ID is stored in the cookie.
(When performing an alert on what the cookie holds, this is what is produces: {"sessions":["7713","7708","7714","7717"]} )
Page Two: (User is logged in) -- PHP page
* Cookie data is received via a GETDATA.
-------------------------------------------------------------------------------------------------
What needs to happen on Page Two is the following:
* After the cookie data has been received, it needs to be sanitized (leaving only the numbers and their comma separators).
* After the sanitization, it needs to be broken apart into an array. I suspect that an explode function will work just fine.
After that, I got the rest. I just need to figure out how to best sanitize the data and get it into a functional state.
ALSO: If anyone can recommend a good way for me to check what values the Cookie is getting in the PHP page, it would be greatly appreciated. Obviously, I cannot do a print_r() because that would break the code as this function is not returning a value.
Thanks.
I have been trying to figure out how this is to be done, but I am losing the battle here.
This is what I have coded so far:
------------------------------------------------------------------------------------------------
Page One: (User is logged out) -- Javascript page
* You add a "session"(s) to your profile.
* This "session"(s) ID is stored in the cookie.
(When performing an alert on what the cookie holds, this is what is produces: {"sessions":["7713","7708","7714","7717"]} )
Page Two: (User is logged in) -- PHP page
* Cookie data is received via a GETDATA.
-------------------------------------------------------------------------------------------------
What needs to happen on Page Two is the following:
* After the cookie data has been received, it needs to be sanitized (leaving only the numbers and their comma separators).
* After the sanitization, it needs to be broken apart into an array. I suspect that an explode function will work just fine.
After that, I got the rest. I just need to figure out how to best sanitize the data and get it into a functional state.
ALSO: If anyone can recommend a good way for me to check what values the Cookie is getting in the PHP page, it would be greatly appreciated. Obviously, I cannot do a print_r() because that would break the code as this function is not returning a value.
Thanks.