Jump to content

Encoding an Array in the URL


kittrellbj

Recommended Posts

This may or may not be the correct forum for this question, but I think it is a general HTML question.

 

I am encoding an array into the URL so that the next page can $_GET the URL, decode it into an array, and display the correct page based on the array.

 

Basically, my URL's are encoded as ...?loc=A01|01|01|01.  So, the PHP pulls the $_GET['loc'] and explodes it into an array.

 

My question is, is it safe to use the | for this operation, or should I use something other than the | character?  I need a special character to separate the values from each other (doesn't matter to me what the character is, really), but I need expert opinion:  is it safe and does it work across multiple platforms?

Link to comment
Share on other sites

Firstly, the Get method will almost never really be a safe way to transport data... It is too easy for anyone to mess around with it, causing errors, or injections...

Secondly, I have never tried passing an array through the Get method... and personally, I suggest either using the Post method, or think about breaking up the array so that you are passing each element of the array, in it's own $_GET array element... (if I remember correctly the $_GET array is not capable of being a multidimensional array, though I could be wrong.)

Link to comment
Share on other sites

A more usual candidate for this is the plus sign, either should be fine.

I'm guessing (got no source to back it up and I could be spouting nonsense) that the plus sign might be part of the ascii that's common across all character sets and might therefore be a bit safer for older browsers (read ancient).

 

Would be nice if someone could step in who actually knows instead of guessing :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.