+ Reply to Thread
Results 1 to 4 of 4

Thread: Cookie arrays

  1. #1
    tommieonos84 is offline x10Hosting Member tommieonos84 is an unknown quantity at this point
    Join Date
    Nov 2010
    Posts
    18

    Exclamation Cookie arrays

    Does anyone know how to store an array in a cookie, and get the value with php?
    It would be nice if i could use Jquery.

    I know how to get the value with php, but how do I get the value there in the first place?
    Code:
    if ($_COOKIE['tabs'][0] == true){
    	echo $_COOKIE['tabs'];
    }etc;

  2. #2
    lemon-tree's Avatar
    lemon-tree is offline x10 Minion lemon-tree has a spectacular aura about
    Join Date
    Nov 2007
    Posts
    1,420

    Re: Cookie arrays

    You cannot directly store the array in a cookie, as it only accepts a key and a string. You will need to serialize the array first and put the resulting string into the cookie. When you want the array back, you then do an unserialize. Note, this will only work for simple arrays, not ones containing instances of classes unless they have been designed for sleeping and waking.

  3. #3
    tommieonos84 is offline x10Hosting Member tommieonos84 is an unknown quantity at this point
    Join Date
    Nov 2010
    Posts
    18

    Re: Cookie arrays

    Thanks a lot, but I can't use serialize since it has to be done on an event like onClick.
    That's why I thought of Jquery

  4. #4
    lemon-tree's Avatar
    lemon-tree is offline x10 Minion lemon-tree has a spectacular aura about
    Join Date
    Nov 2007
    Posts
    1,420

    Re: Cookie arrays

    So you want to put it there with Javascript and then read with PHP? If so, you could try using JSON as the transfer language; both PHP and Javascript have support for it, so it's likely your best bet.

+ Reply to Thread

Similar Threads

  1. Who ate the last cookie?
    By cybrax in forum Off Topic
    Replies: 4
    Last Post: 03-14-2011, 12:47 AM
  2. JFusion + SMF Cookie Help!
    By h4nbury in forum Free Hosting
    Replies: 0
    Last Post: 07-21-2009, 06:08 AM
  3. Unix Arrays
    By kbjradmin in forum Programming Help
    Replies: 8
    Last Post: 02-09-2009, 09:55 PM
  4. Cookie Help (the one below didn't help)
    By jasgor9 in forum Programming Help
    Replies: 4
    Last Post: 04-13-2008, 07:00 PM
  5. Cookie Troubles
    By chr0n1x in forum Free Hosting
    Replies: 3
    Last Post: 10-21-2005, 02:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers