php cookie with % in value











up vote
0
down vote

favorite












as php noob I have a problem with php setcookie. I try to achive a cookie which value is "bid_1%257C1544538505%257Ced2d154bb51e2a989fb30fe4250ce602" with php.
This I tried so far... .



$cookieName = 'test';
$value = 'bid_1%7C1544538505%7Ced2d154bb51e2a989fb30fe4250ce602';
$setcookie($cookieName, $value, time()+3600);


What I get is a cookie with a value of:



  bid_1%257C1544538505%257Ced2d154bb51e2a989fb30fe4250ce602


How can I achive a correct value and prevent php from transforming "%". Many Thanks in advance.



I tried without success



 $value =    'bid_1%%7C1544538505%%7Ced2d154bb51e2a989fb30fe4250ce602';// and
$value = 'bid_1%7C1544538505%7Ced2d154bb51e2a989fb30fe4250ce602';









share|improve this question




















  • 1




    I suggest looking at php setrawcookie which might resolve your problem
    – Jérôme B
    Nov 21 at 15:16












  • @JérômeB this was exactly, what resolved my problem. Thanks a bunch!
    – Friedrich Siever
    Nov 21 at 15:24















up vote
0
down vote

favorite












as php noob I have a problem with php setcookie. I try to achive a cookie which value is "bid_1%257C1544538505%257Ced2d154bb51e2a989fb30fe4250ce602" with php.
This I tried so far... .



$cookieName = 'test';
$value = 'bid_1%7C1544538505%7Ced2d154bb51e2a989fb30fe4250ce602';
$setcookie($cookieName, $value, time()+3600);


What I get is a cookie with a value of:



  bid_1%257C1544538505%257Ced2d154bb51e2a989fb30fe4250ce602


How can I achive a correct value and prevent php from transforming "%". Many Thanks in advance.



I tried without success



 $value =    'bid_1%%7C1544538505%%7Ced2d154bb51e2a989fb30fe4250ce602';// and
$value = 'bid_1%7C1544538505%7Ced2d154bb51e2a989fb30fe4250ce602';









share|improve this question




















  • 1




    I suggest looking at php setrawcookie which might resolve your problem
    – Jérôme B
    Nov 21 at 15:16












  • @JérômeB this was exactly, what resolved my problem. Thanks a bunch!
    – Friedrich Siever
    Nov 21 at 15:24













up vote
0
down vote

favorite









up vote
0
down vote

favorite











as php noob I have a problem with php setcookie. I try to achive a cookie which value is "bid_1%257C1544538505%257Ced2d154bb51e2a989fb30fe4250ce602" with php.
This I tried so far... .



$cookieName = 'test';
$value = 'bid_1%7C1544538505%7Ced2d154bb51e2a989fb30fe4250ce602';
$setcookie($cookieName, $value, time()+3600);


What I get is a cookie with a value of:



  bid_1%257C1544538505%257Ced2d154bb51e2a989fb30fe4250ce602


How can I achive a correct value and prevent php from transforming "%". Many Thanks in advance.



I tried without success



 $value =    'bid_1%%7C1544538505%%7Ced2d154bb51e2a989fb30fe4250ce602';// and
$value = 'bid_1%7C1544538505%7Ced2d154bb51e2a989fb30fe4250ce602';









share|improve this question















as php noob I have a problem with php setcookie. I try to achive a cookie which value is "bid_1%257C1544538505%257Ced2d154bb51e2a989fb30fe4250ce602" with php.
This I tried so far... .



$cookieName = 'test';
$value = 'bid_1%7C1544538505%7Ced2d154bb51e2a989fb30fe4250ce602';
$setcookie($cookieName, $value, time()+3600);


What I get is a cookie with a value of:



  bid_1%257C1544538505%257Ced2d154bb51e2a989fb30fe4250ce602


How can I achive a correct value and prevent php from transforming "%". Many Thanks in advance.



I tried without success



 $value =    'bid_1%%7C1544538505%%7Ced2d154bb51e2a989fb30fe4250ce602';// and
$value = 'bid_1%7C1544538505%7Ced2d154bb51e2a989fb30fe4250ce602';






php cookies setcookie






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 at 15:17

























asked Nov 21 at 14:53









Friedrich Siever

947




947








  • 1




    I suggest looking at php setrawcookie which might resolve your problem
    – Jérôme B
    Nov 21 at 15:16












  • @JérômeB this was exactly, what resolved my problem. Thanks a bunch!
    – Friedrich Siever
    Nov 21 at 15:24














  • 1




    I suggest looking at php setrawcookie which might resolve your problem
    – Jérôme B
    Nov 21 at 15:16












  • @JérômeB this was exactly, what resolved my problem. Thanks a bunch!
    – Friedrich Siever
    Nov 21 at 15:24








1




1




I suggest looking at php setrawcookie which might resolve your problem
– Jérôme B
Nov 21 at 15:16






I suggest looking at php setrawcookie which might resolve your problem
– Jérôme B
Nov 21 at 15:16














@JérômeB this was exactly, what resolved my problem. Thanks a bunch!
– Friedrich Siever
Nov 21 at 15:24




@JérômeB this was exactly, what resolved my problem. Thanks a bunch!
– Friedrich Siever
Nov 21 at 15:24












2 Answers
2






active

oldest

votes

















up vote
1
down vote



accepted










Basically the root problem is that setcookie encodes your value, therefore some characters like % are encoded as %25



Solution



setrawcookie doesn't have this feature and therefore returns the result you want






share|improve this answer























  • No, the root problem is that they are trying to re-encode something that they already ran through urlencode(). (That's not to say your answer won't work of course.)
    – miken32
    Nov 21 at 16:56


















up vote
2
down vote














What I get is a cookie with a value of




No. What you quoted there is a representation of the actual value. What is stored on the client, and is returned in subsequent requests is the same value you passed as an argument to setcookie().






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53414721%2fphp-cookie-with-in-value%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    Basically the root problem is that setcookie encodes your value, therefore some characters like % are encoded as %25



    Solution



    setrawcookie doesn't have this feature and therefore returns the result you want






    share|improve this answer























    • No, the root problem is that they are trying to re-encode something that they already ran through urlencode(). (That's not to say your answer won't work of course.)
      – miken32
      Nov 21 at 16:56















    up vote
    1
    down vote



    accepted










    Basically the root problem is that setcookie encodes your value, therefore some characters like % are encoded as %25



    Solution



    setrawcookie doesn't have this feature and therefore returns the result you want






    share|improve this answer























    • No, the root problem is that they are trying to re-encode something that they already ran through urlencode(). (That's not to say your answer won't work of course.)
      – miken32
      Nov 21 at 16:56













    up vote
    1
    down vote



    accepted







    up vote
    1
    down vote



    accepted






    Basically the root problem is that setcookie encodes your value, therefore some characters like % are encoded as %25



    Solution



    setrawcookie doesn't have this feature and therefore returns the result you want






    share|improve this answer














    Basically the root problem is that setcookie encodes your value, therefore some characters like % are encoded as %25



    Solution



    setrawcookie doesn't have this feature and therefore returns the result you want







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 21 at 15:47

























    answered Nov 21 at 15:38









    Jérôme B

    10112




    10112












    • No, the root problem is that they are trying to re-encode something that they already ran through urlencode(). (That's not to say your answer won't work of course.)
      – miken32
      Nov 21 at 16:56


















    • No, the root problem is that they are trying to re-encode something that they already ran through urlencode(). (That's not to say your answer won't work of course.)
      – miken32
      Nov 21 at 16:56
















    No, the root problem is that they are trying to re-encode something that they already ran through urlencode(). (That's not to say your answer won't work of course.)
    – miken32
    Nov 21 at 16:56




    No, the root problem is that they are trying to re-encode something that they already ran through urlencode(). (That's not to say your answer won't work of course.)
    – miken32
    Nov 21 at 16:56












    up vote
    2
    down vote














    What I get is a cookie with a value of




    No. What you quoted there is a representation of the actual value. What is stored on the client, and is returned in subsequent requests is the same value you passed as an argument to setcookie().






    share|improve this answer

























      up vote
      2
      down vote














      What I get is a cookie with a value of




      No. What you quoted there is a representation of the actual value. What is stored on the client, and is returned in subsequent requests is the same value you passed as an argument to setcookie().






      share|improve this answer























        up vote
        2
        down vote










        up vote
        2
        down vote










        What I get is a cookie with a value of




        No. What you quoted there is a representation of the actual value. What is stored on the client, and is returned in subsequent requests is the same value you passed as an argument to setcookie().






        share|improve this answer













        What I get is a cookie with a value of




        No. What you quoted there is a representation of the actual value. What is stored on the client, and is returned in subsequent requests is the same value you passed as an argument to setcookie().







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 at 15:18









        symcbean

        40.6k44076




        40.6k44076






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53414721%2fphp-cookie-with-in-value%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Berounka

            Sphinx de Gizeh

            Different font size/position of beamer's navigation symbols template's content depending on regular/plain...