how to retrieve session in laravel 5.6?












0














edit function



 public function editNotice(Request $request,$id=null){
if(Session::has('idSession')){
if($request->isMethod('post')){

$data = $request->all();
$test = $data['death_name'];
Session::put('death_name',$test);


} else {
return redirect('/user')->with('flash_message_error','Please Login First to access..');
}
}


verifyEditNotice function



public function verifyEditNotice(Request $request,$id=null){

$new = Session::get('death_name');
echo $new;die;
}


here, i have saved death name in session in edit function and i want to retieve the session value in verify edit function.
but the problem is when I retrieve it shows null.
How do i get the value in another function..










share|improve this question





























    0














    edit function



     public function editNotice(Request $request,$id=null){
    if(Session::has('idSession')){
    if($request->isMethod('post')){

    $data = $request->all();
    $test = $data['death_name'];
    Session::put('death_name',$test);


    } else {
    return redirect('/user')->with('flash_message_error','Please Login First to access..');
    }
    }


    verifyEditNotice function



    public function verifyEditNotice(Request $request,$id=null){

    $new = Session::get('death_name');
    echo $new;die;
    }


    here, i have saved death name in session in edit function and i want to retieve the session value in verify edit function.
    but the problem is when I retrieve it shows null.
    How do i get the value in another function..










    share|improve this question



























      0












      0








      0







      edit function



       public function editNotice(Request $request,$id=null){
      if(Session::has('idSession')){
      if($request->isMethod('post')){

      $data = $request->all();
      $test = $data['death_name'];
      Session::put('death_name',$test);


      } else {
      return redirect('/user')->with('flash_message_error','Please Login First to access..');
      }
      }


      verifyEditNotice function



      public function verifyEditNotice(Request $request,$id=null){

      $new = Session::get('death_name');
      echo $new;die;
      }


      here, i have saved death name in session in edit function and i want to retieve the session value in verify edit function.
      but the problem is when I retrieve it shows null.
      How do i get the value in another function..










      share|improve this question















      edit function



       public function editNotice(Request $request,$id=null){
      if(Session::has('idSession')){
      if($request->isMethod('post')){

      $data = $request->all();
      $test = $data['death_name'];
      Session::put('death_name',$test);


      } else {
      return redirect('/user')->with('flash_message_error','Please Login First to access..');
      }
      }


      verifyEditNotice function



      public function verifyEditNotice(Request $request,$id=null){

      $new = Session::get('death_name');
      echo $new;die;
      }


      here, i have saved death name in session in edit function and i want to retieve the session value in verify edit function.
      but the problem is when I retrieve it shows null.
      How do i get the value in another function..







      php laravel laravel-5






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 13 '18 at 8:58









      Vadim Kotov

      4,35153247




      4,35153247










      asked Nov 13 '18 at 8:47









      Prem BasnetPrem Basnet

      116




      116
























          3 Answers
          3






          active

          oldest

          votes


















          1














          According to laravel documentation you can get it as like below



          public function verifyEditNotice(Request $request,$id=null){
          $session_value = $request->session()->get('death_name');
          dd($session_value); // debug it and die
          }


          Also laravel give you debug function dd(); which will debug provided variable so you don't need to use die()






          share|improve this answer





















          • it gives only null...
            – Prem Basnet
            Nov 13 '18 at 9:06



















          0














          Laravel provides helper functions and one of them is session()



          Example:



          session()->flash('success', 'This is a flash message!');
          or in your case
          session()->get('death_name');


          Try dumping the variable using dd(), another very useful helper function in the Laravel framework.






          share|improve this answer





















          • it only gives null
            – Prem Basnet
            Nov 13 '18 at 9:07



















          0














           public function editNotice(Request $request,$id=null){
          if(Session::has('idSession')){
          // 1. First try
          dd($request->all()); //check if control gets to this line


          if($request->isMethod('post')){
          // 2. Second try
          dd($request->all()); // check if control gets to this line

          $data = $request->all();
          $test = $data['death_name'];

          // Session::put('death_name',$test);
          $request->session()->put('death_name', $test);


          ///////////////////// 3. Third try
          dd(session('death_name')); // check if control gets to this line
          } else {
          return redirect('/user')->with('flash_message_error','Please Login First to
          access..');
          }
          }


          Debug using above code :



          if you get to the step 3 and still gets NULL/Empty



          Go to your {project_root}/storage folder and give 775 permission and ownership to www-data



          Use following commands:



          {project_root}> sudo chown -R www-data:www-data storage/



          {project_root}> sudo chmod -R 775 storage/



          if above doesn't work try it with 777



          if 777 also doesn't work



          Verify your configuration.



          https://laravel.com/docs/5.7/session#configuration






          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%2f53277040%2fhow-to-retrieve-session-in-laravel-5-6%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            According to laravel documentation you can get it as like below



            public function verifyEditNotice(Request $request,$id=null){
            $session_value = $request->session()->get('death_name');
            dd($session_value); // debug it and die
            }


            Also laravel give you debug function dd(); which will debug provided variable so you don't need to use die()






            share|improve this answer





















            • it gives only null...
              – Prem Basnet
              Nov 13 '18 at 9:06
















            1














            According to laravel documentation you can get it as like below



            public function verifyEditNotice(Request $request,$id=null){
            $session_value = $request->session()->get('death_name');
            dd($session_value); // debug it and die
            }


            Also laravel give you debug function dd(); which will debug provided variable so you don't need to use die()






            share|improve this answer





















            • it gives only null...
              – Prem Basnet
              Nov 13 '18 at 9:06














            1












            1








            1






            According to laravel documentation you can get it as like below



            public function verifyEditNotice(Request $request,$id=null){
            $session_value = $request->session()->get('death_name');
            dd($session_value); // debug it and die
            }


            Also laravel give you debug function dd(); which will debug provided variable so you don't need to use die()






            share|improve this answer












            According to laravel documentation you can get it as like below



            public function verifyEditNotice(Request $request,$id=null){
            $session_value = $request->session()->get('death_name');
            dd($session_value); // debug it and die
            }


            Also laravel give you debug function dd(); which will debug provided variable so you don't need to use die()







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 13 '18 at 8:49









            Ayaz ShahAyaz Shah

            2,15231647




            2,15231647












            • it gives only null...
              – Prem Basnet
              Nov 13 '18 at 9:06


















            • it gives only null...
              – Prem Basnet
              Nov 13 '18 at 9:06
















            it gives only null...
            – Prem Basnet
            Nov 13 '18 at 9:06




            it gives only null...
            – Prem Basnet
            Nov 13 '18 at 9:06













            0














            Laravel provides helper functions and one of them is session()



            Example:



            session()->flash('success', 'This is a flash message!');
            or in your case
            session()->get('death_name');


            Try dumping the variable using dd(), another very useful helper function in the Laravel framework.






            share|improve this answer





















            • it only gives null
              – Prem Basnet
              Nov 13 '18 at 9:07
















            0














            Laravel provides helper functions and one of them is session()



            Example:



            session()->flash('success', 'This is a flash message!');
            or in your case
            session()->get('death_name');


            Try dumping the variable using dd(), another very useful helper function in the Laravel framework.






            share|improve this answer





















            • it only gives null
              – Prem Basnet
              Nov 13 '18 at 9:07














            0












            0








            0






            Laravel provides helper functions and one of them is session()



            Example:



            session()->flash('success', 'This is a flash message!');
            or in your case
            session()->get('death_name');


            Try dumping the variable using dd(), another very useful helper function in the Laravel framework.






            share|improve this answer












            Laravel provides helper functions and one of them is session()



            Example:



            session()->flash('success', 'This is a flash message!');
            or in your case
            session()->get('death_name');


            Try dumping the variable using dd(), another very useful helper function in the Laravel framework.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 13 '18 at 8:53









            SagunKhoSagunKho

            371216




            371216












            • it only gives null
              – Prem Basnet
              Nov 13 '18 at 9:07


















            • it only gives null
              – Prem Basnet
              Nov 13 '18 at 9:07
















            it only gives null
            – Prem Basnet
            Nov 13 '18 at 9:07




            it only gives null
            – Prem Basnet
            Nov 13 '18 at 9:07











            0














             public function editNotice(Request $request,$id=null){
            if(Session::has('idSession')){
            // 1. First try
            dd($request->all()); //check if control gets to this line


            if($request->isMethod('post')){
            // 2. Second try
            dd($request->all()); // check if control gets to this line

            $data = $request->all();
            $test = $data['death_name'];

            // Session::put('death_name',$test);
            $request->session()->put('death_name', $test);


            ///////////////////// 3. Third try
            dd(session('death_name')); // check if control gets to this line
            } else {
            return redirect('/user')->with('flash_message_error','Please Login First to
            access..');
            }
            }


            Debug using above code :



            if you get to the step 3 and still gets NULL/Empty



            Go to your {project_root}/storage folder and give 775 permission and ownership to www-data



            Use following commands:



            {project_root}> sudo chown -R www-data:www-data storage/



            {project_root}> sudo chmod -R 775 storage/



            if above doesn't work try it with 777



            if 777 also doesn't work



            Verify your configuration.



            https://laravel.com/docs/5.7/session#configuration






            share|improve this answer


























              0














               public function editNotice(Request $request,$id=null){
              if(Session::has('idSession')){
              // 1. First try
              dd($request->all()); //check if control gets to this line


              if($request->isMethod('post')){
              // 2. Second try
              dd($request->all()); // check if control gets to this line

              $data = $request->all();
              $test = $data['death_name'];

              // Session::put('death_name',$test);
              $request->session()->put('death_name', $test);


              ///////////////////// 3. Third try
              dd(session('death_name')); // check if control gets to this line
              } else {
              return redirect('/user')->with('flash_message_error','Please Login First to
              access..');
              }
              }


              Debug using above code :



              if you get to the step 3 and still gets NULL/Empty



              Go to your {project_root}/storage folder and give 775 permission and ownership to www-data



              Use following commands:



              {project_root}> sudo chown -R www-data:www-data storage/



              {project_root}> sudo chmod -R 775 storage/



              if above doesn't work try it with 777



              if 777 also doesn't work



              Verify your configuration.



              https://laravel.com/docs/5.7/session#configuration






              share|improve this answer
























                0












                0








                0






                 public function editNotice(Request $request,$id=null){
                if(Session::has('idSession')){
                // 1. First try
                dd($request->all()); //check if control gets to this line


                if($request->isMethod('post')){
                // 2. Second try
                dd($request->all()); // check if control gets to this line

                $data = $request->all();
                $test = $data['death_name'];

                // Session::put('death_name',$test);
                $request->session()->put('death_name', $test);


                ///////////////////// 3. Third try
                dd(session('death_name')); // check if control gets to this line
                } else {
                return redirect('/user')->with('flash_message_error','Please Login First to
                access..');
                }
                }


                Debug using above code :



                if you get to the step 3 and still gets NULL/Empty



                Go to your {project_root}/storage folder and give 775 permission and ownership to www-data



                Use following commands:



                {project_root}> sudo chown -R www-data:www-data storage/



                {project_root}> sudo chmod -R 775 storage/



                if above doesn't work try it with 777



                if 777 also doesn't work



                Verify your configuration.



                https://laravel.com/docs/5.7/session#configuration






                share|improve this answer












                 public function editNotice(Request $request,$id=null){
                if(Session::has('idSession')){
                // 1. First try
                dd($request->all()); //check if control gets to this line


                if($request->isMethod('post')){
                // 2. Second try
                dd($request->all()); // check if control gets to this line

                $data = $request->all();
                $test = $data['death_name'];

                // Session::put('death_name',$test);
                $request->session()->put('death_name', $test);


                ///////////////////// 3. Third try
                dd(session('death_name')); // check if control gets to this line
                } else {
                return redirect('/user')->with('flash_message_error','Please Login First to
                access..');
                }
                }


                Debug using above code :



                if you get to the step 3 and still gets NULL/Empty



                Go to your {project_root}/storage folder and give 775 permission and ownership to www-data



                Use following commands:



                {project_root}> sudo chown -R www-data:www-data storage/



                {project_root}> sudo chmod -R 775 storage/



                if above doesn't work try it with 777



                if 777 also doesn't work



                Verify your configuration.



                https://laravel.com/docs/5.7/session#configuration







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 13 '18 at 9:09









                Omar AbdullahOmar Abdullah

                1967




                1967






























                    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%2f53277040%2fhow-to-retrieve-session-in-laravel-5-6%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

                    Xamarin.iOS Cant Deploy on Iphone

                    Glorious Revolution

                    Dulmage-Mendelsohn matrix decomposition in Python