Check if cookie is existing returns all aray












1














I am trying to check if cookie is stored or not. If not existing, it returns all the stored cookies in an application. It's supposed to be null, right?



$cookie = $request->cookie(config('app.name' .'_VERIFIED'));
dump($cookie);


This code above, if cookie is not existing, returns all stored cookies. If existing, then it will return the value. I want a null value if not existing.










share|improve this question



























    1














    I am trying to check if cookie is stored or not. If not existing, it returns all the stored cookies in an application. It's supposed to be null, right?



    $cookie = $request->cookie(config('app.name' .'_VERIFIED'));
    dump($cookie);


    This code above, if cookie is not existing, returns all stored cookies. If existing, then it will return the value. I want a null value if not existing.










    share|improve this question

























      1












      1








      1







      I am trying to check if cookie is stored or not. If not existing, it returns all the stored cookies in an application. It's supposed to be null, right?



      $cookie = $request->cookie(config('app.name' .'_VERIFIED'));
      dump($cookie);


      This code above, if cookie is not existing, returns all stored cookies. If existing, then it will return the value. I want a null value if not existing.










      share|improve this question













      I am trying to check if cookie is stored or not. If not existing, it returns all the stored cookies in an application. It's supposed to be null, right?



      $cookie = $request->cookie(config('app.name' .'_VERIFIED'));
      dump($cookie);


      This code above, if cookie is not existing, returns all stored cookies. If existing, then it will return the value. I want a null value if not existing.







      laravel cookies






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 19 '18 at 14:06









      MiniDr

      6717




      6717
























          2 Answers
          2






          active

          oldest

          votes


















          1














          What you want is the default behavior of laravel. But if the first parameter of $request->cookie() is null it will return all cookie values. You have to make sure that you always get a value from config('app.name' .'_VERIFIED')






          share|improve this answer





























            1














            The way method $request->cookie work is, when you past a key to the cookie function, It will call the cookie method which is define in IlluminateHttpConcerns Concern which call the retrieveItem method which take the cookies is define like this



             protected function retrieveItem($source, $key, $default){}


            the $source parameter will set to cookies and the $key will be set to the key you past, if the key is set to null, it will return all content of the cookie object. if $key is not null it will call the method get on the cookies source which is of type SymfonyComponentHttpFoundationParameterBag like define in the SymfonyComponentHttpFoundationRequest which is the class that IlluminateHttpRequest class extends. Which return the content of key depending of it value.






            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',
              autoActivateHeartbeat: false,
              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%2f53376381%2fcheck-if-cookie-is-existing-returns-all-aray%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









              1














              What you want is the default behavior of laravel. But if the first parameter of $request->cookie() is null it will return all cookie values. You have to make sure that you always get a value from config('app.name' .'_VERIFIED')






              share|improve this answer


























                1














                What you want is the default behavior of laravel. But if the first parameter of $request->cookie() is null it will return all cookie values. You have to make sure that you always get a value from config('app.name' .'_VERIFIED')






                share|improve this answer
























                  1












                  1








                  1






                  What you want is the default behavior of laravel. But if the first parameter of $request->cookie() is null it will return all cookie values. You have to make sure that you always get a value from config('app.name' .'_VERIFIED')






                  share|improve this answer












                  What you want is the default behavior of laravel. But if the first parameter of $request->cookie() is null it will return all cookie values. You have to make sure that you always get a value from config('app.name' .'_VERIFIED')







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 19 '18 at 14:30









                  Remul

                  1,1181113




                  1,1181113

























                      1














                      The way method $request->cookie work is, when you past a key to the cookie function, It will call the cookie method which is define in IlluminateHttpConcerns Concern which call the retrieveItem method which take the cookies is define like this



                       protected function retrieveItem($source, $key, $default){}


                      the $source parameter will set to cookies and the $key will be set to the key you past, if the key is set to null, it will return all content of the cookie object. if $key is not null it will call the method get on the cookies source which is of type SymfonyComponentHttpFoundationParameterBag like define in the SymfonyComponentHttpFoundationRequest which is the class that IlluminateHttpRequest class extends. Which return the content of key depending of it value.






                      share|improve this answer


























                        1














                        The way method $request->cookie work is, when you past a key to the cookie function, It will call the cookie method which is define in IlluminateHttpConcerns Concern which call the retrieveItem method which take the cookies is define like this



                         protected function retrieveItem($source, $key, $default){}


                        the $source parameter will set to cookies and the $key will be set to the key you past, if the key is set to null, it will return all content of the cookie object. if $key is not null it will call the method get on the cookies source which is of type SymfonyComponentHttpFoundationParameterBag like define in the SymfonyComponentHttpFoundationRequest which is the class that IlluminateHttpRequest class extends. Which return the content of key depending of it value.






                        share|improve this answer
























                          1












                          1








                          1






                          The way method $request->cookie work is, when you past a key to the cookie function, It will call the cookie method which is define in IlluminateHttpConcerns Concern which call the retrieveItem method which take the cookies is define like this



                           protected function retrieveItem($source, $key, $default){}


                          the $source parameter will set to cookies and the $key will be set to the key you past, if the key is set to null, it will return all content of the cookie object. if $key is not null it will call the method get on the cookies source which is of type SymfonyComponentHttpFoundationParameterBag like define in the SymfonyComponentHttpFoundationRequest which is the class that IlluminateHttpRequest class extends. Which return the content of key depending of it value.






                          share|improve this answer












                          The way method $request->cookie work is, when you past a key to the cookie function, It will call the cookie method which is define in IlluminateHttpConcerns Concern which call the retrieveItem method which take the cookies is define like this



                           protected function retrieveItem($source, $key, $default){}


                          the $source parameter will set to cookies and the $key will be set to the key you past, if the key is set to null, it will return all content of the cookie object. if $key is not null it will call the method get on the cookies source which is of type SymfonyComponentHttpFoundationParameterBag like define in the SymfonyComponentHttpFoundationRequest which is the class that IlluminateHttpRequest class extends. Which return the content of key depending of it value.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 19 '18 at 14:51









                          Yves Kipondo

                          1,340414




                          1,340414






























                              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%2f53376381%2fcheck-if-cookie-is-existing-returns-all-aray%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

                              android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

                              SQL update select statement

                              'app-layout' is not a known element: how to share Component with different Modules