php unseting $_SESSION variable on page referesh or redirected












2















I have moved our code to new server PHP version is 7.1 previously used were 5.6.



I am facing problems on $_SESSION variable. if page is redirected to other pages $_SESSION is have no values, even I reload this page again after commented session set as well $_SESSION values are gone.



ob_start(); session_start();
$_SESSION['abc'] = "manik";
echo "<pre>";
print_r($_SESSION);
echo "</pre>";
session_regenerate_id(true);
header('Location:test2.php');
exit();


session_save_path



Please advise.










share|improve this question

























  • So you code was working in same browser using old PHP version ?

    – Soheyl
    Jan 1 at 11:52











  • yes when moved to new server its not working , i think its something session_save_path issue, local is saved there but master value not

    – arvindpundir
    Jan 1 at 12:47











  • So remove session_save_path from your script and test it with default tmp folder to see if it works :)

    – Soheyl
    Jan 1 at 13:17











  • no its not working with temp folder as well

    – arvindpundir
    Jan 2 at 4:06











  • Do you get any error ?

    – Soheyl
    Jan 2 at 11:53
















2















I have moved our code to new server PHP version is 7.1 previously used were 5.6.



I am facing problems on $_SESSION variable. if page is redirected to other pages $_SESSION is have no values, even I reload this page again after commented session set as well $_SESSION values are gone.



ob_start(); session_start();
$_SESSION['abc'] = "manik";
echo "<pre>";
print_r($_SESSION);
echo "</pre>";
session_regenerate_id(true);
header('Location:test2.php');
exit();


session_save_path



Please advise.










share|improve this question

























  • So you code was working in same browser using old PHP version ?

    – Soheyl
    Jan 1 at 11:52











  • yes when moved to new server its not working , i think its something session_save_path issue, local is saved there but master value not

    – arvindpundir
    Jan 1 at 12:47











  • So remove session_save_path from your script and test it with default tmp folder to see if it works :)

    – Soheyl
    Jan 1 at 13:17











  • no its not working with temp folder as well

    – arvindpundir
    Jan 2 at 4:06











  • Do you get any error ?

    – Soheyl
    Jan 2 at 11:53














2












2








2


3






I have moved our code to new server PHP version is 7.1 previously used were 5.6.



I am facing problems on $_SESSION variable. if page is redirected to other pages $_SESSION is have no values, even I reload this page again after commented session set as well $_SESSION values are gone.



ob_start(); session_start();
$_SESSION['abc'] = "manik";
echo "<pre>";
print_r($_SESSION);
echo "</pre>";
session_regenerate_id(true);
header('Location:test2.php');
exit();


session_save_path



Please advise.










share|improve this question
















I have moved our code to new server PHP version is 7.1 previously used were 5.6.



I am facing problems on $_SESSION variable. if page is redirected to other pages $_SESSION is have no values, even I reload this page again after commented session set as well $_SESSION values are gone.



ob_start(); session_start();
$_SESSION['abc'] = "manik";
echo "<pre>";
print_r($_SESSION);
echo "</pre>";
session_regenerate_id(true);
header('Location:test2.php');
exit();


session_save_path



Please advise.







php session session-variables






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 1 at 10:49







arvindpundir

















asked Jan 1 at 10:28









arvindpundirarvindpundir

587




587













  • So you code was working in same browser using old PHP version ?

    – Soheyl
    Jan 1 at 11:52











  • yes when moved to new server its not working , i think its something session_save_path issue, local is saved there but master value not

    – arvindpundir
    Jan 1 at 12:47











  • So remove session_save_path from your script and test it with default tmp folder to see if it works :)

    – Soheyl
    Jan 1 at 13:17











  • no its not working with temp folder as well

    – arvindpundir
    Jan 2 at 4:06











  • Do you get any error ?

    – Soheyl
    Jan 2 at 11:53



















  • So you code was working in same browser using old PHP version ?

    – Soheyl
    Jan 1 at 11:52











  • yes when moved to new server its not working , i think its something session_save_path issue, local is saved there but master value not

    – arvindpundir
    Jan 1 at 12:47











  • So remove session_save_path from your script and test it with default tmp folder to see if it works :)

    – Soheyl
    Jan 1 at 13:17











  • no its not working with temp folder as well

    – arvindpundir
    Jan 2 at 4:06











  • Do you get any error ?

    – Soheyl
    Jan 2 at 11:53

















So you code was working in same browser using old PHP version ?

– Soheyl
Jan 1 at 11:52





So you code was working in same browser using old PHP version ?

– Soheyl
Jan 1 at 11:52













yes when moved to new server its not working , i think its something session_save_path issue, local is saved there but master value not

– arvindpundir
Jan 1 at 12:47





yes when moved to new server its not working , i think its something session_save_path issue, local is saved there but master value not

– arvindpundir
Jan 1 at 12:47













So remove session_save_path from your script and test it with default tmp folder to see if it works :)

– Soheyl
Jan 1 at 13:17





So remove session_save_path from your script and test it with default tmp folder to see if it works :)

– Soheyl
Jan 1 at 13:17













no its not working with temp folder as well

– arvindpundir
Jan 2 at 4:06





no its not working with temp folder as well

– arvindpundir
Jan 2 at 4:06













Do you get any error ?

– Soheyl
Jan 2 at 11:53





Do you get any error ?

– Soheyl
Jan 2 at 11:53












2 Answers
2






active

oldest

votes


















1














you can check you session.save_path i THINK SO ITS NOT writable That's why ur facing this issue
if (!is_writable(session_save_path()))
{
echo 'Session path "'.session_save_path().'" is not writable for PHP!';
}






share|improve this answer































    0














    save your variables in an array first. Then, set session data using set_userdata method.
    Example:



    $session_data = array('abc' => 'manik');


    Then,



    $this->session->set_userdata($session_data);


    Hope, this works






    share|improve this answer
























    • its php project not the codeigniter one , thanks

      – arvindpundir
      Jan 2 at 4:41











    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%2f53994720%2fphp-unseting-session-variable-on-page-referesh-or-redirected%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














    you can check you session.save_path i THINK SO ITS NOT writable That's why ur facing this issue
    if (!is_writable(session_save_path()))
    {
    echo 'Session path "'.session_save_path().'" is not writable for PHP!';
    }






    share|improve this answer




























      1














      you can check you session.save_path i THINK SO ITS NOT writable That's why ur facing this issue
      if (!is_writable(session_save_path()))
      {
      echo 'Session path "'.session_save_path().'" is not writable for PHP!';
      }






      share|improve this answer


























        1












        1








        1







        you can check you session.save_path i THINK SO ITS NOT writable That's why ur facing this issue
        if (!is_writable(session_save_path()))
        {
        echo 'Session path "'.session_save_path().'" is not writable for PHP!';
        }






        share|improve this answer













        you can check you session.save_path i THINK SO ITS NOT writable That's why ur facing this issue
        if (!is_writable(session_save_path()))
        {
        echo 'Session path "'.session_save_path().'" is not writable for PHP!';
        }







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 8 at 11:37









        Manik khannaManik khanna

        388




        388

























            0














            save your variables in an array first. Then, set session data using set_userdata method.
            Example:



            $session_data = array('abc' => 'manik');


            Then,



            $this->session->set_userdata($session_data);


            Hope, this works






            share|improve this answer
























            • its php project not the codeigniter one , thanks

              – arvindpundir
              Jan 2 at 4:41
















            0














            save your variables in an array first. Then, set session data using set_userdata method.
            Example:



            $session_data = array('abc' => 'manik');


            Then,



            $this->session->set_userdata($session_data);


            Hope, this works






            share|improve this answer
























            • its php project not the codeigniter one , thanks

              – arvindpundir
              Jan 2 at 4:41














            0












            0








            0







            save your variables in an array first. Then, set session data using set_userdata method.
            Example:



            $session_data = array('abc' => 'manik');


            Then,



            $this->session->set_userdata($session_data);


            Hope, this works






            share|improve this answer













            save your variables in an array first. Then, set session data using set_userdata method.
            Example:



            $session_data = array('abc' => 'manik');


            Then,



            $this->session->set_userdata($session_data);


            Hope, this works







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 1 at 12:03









            Rakib Ibna HamidRakib Ibna Hamid

            345




            345













            • its php project not the codeigniter one , thanks

              – arvindpundir
              Jan 2 at 4:41



















            • its php project not the codeigniter one , thanks

              – arvindpundir
              Jan 2 at 4:41

















            its php project not the codeigniter one , thanks

            – arvindpundir
            Jan 2 at 4:41





            its php project not the codeigniter one , thanks

            – arvindpundir
            Jan 2 at 4:41


















            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53994720%2fphp-unseting-session-variable-on-page-referesh-or-redirected%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

            Mossoró

            Error while reading .h5 file using the rhdf5 package in R

            Pushsharp Apns notification error: 'InvalidToken'