PHP Session not Saving

前端 未结 9 1063
情话喂你
情话喂你 2020-12-03 17:39

I have this written at the very first line on every page of my website.

include(\"restd.php\");

and restd.php contains the following lines

相关标签:
9条回答
  • 2020-12-03 17:56

    Do you actually set $_SESSION['id'] on a page...

    What you are trying to do here is:

    1. Start a session and load the $_SESSION from the session handler
    2. Check if $_SESSION contains key 'id'
    3. Redirect to index.php if $_SESSION['id'] is not set

    Do you actually do this in index.php?

    session_start();
    $_SESSION['id'] = something;
    
    0 讨论(0)
  • 2020-12-03 18:05

    Check maybe your session path does not exist so you can save PHP session path using:

    ini_set(' session.save_path','SOME WRITABLE PATH');
    
    0 讨论(0)
  • 2020-12-03 18:12

    I know this is an old thread, but the following helped me with the same problem after hours of despair. Found on: http://php.net/manual/de/function.session-save-path.php

    I made a folder next to the public html folder and placed these lines at the very first point in index.php

    Location of session folder:

    /domains/account/session

    location of index.php

    /domains/account/public_html/index.php

    What I placed in index.php at line 0:

    <?php 
    ini_set('session.save_path',realpath(dirname($_SERVER['DOCUMENT_ROOT']) . '/../session'));
    session_start();
    ?>
    

    Hopefully this will save you time.

    0 讨论(0)
提交回复
热议问题