phpsessionid

PHP session_id( ) null


I am having some difficulty with sessions.

On my local MAMP test server, if I do:

session_start( ); echo session_id( );

I get a nice looking session id.

If However, I the same thing on my web server, all I can get back from session_id is 'null'. Testing the return from session_start( ) and using sessions everything is working, but session_id( ) $SID and $PHPSESSID are all null.

Is this hidden on purpose for added security? I want to be able to allow flash to make changes to a shopping cart through PHP calls and have the cart (which is stored in the session) reflected using the browser.


Solution

  • Make sure the return value of session_start() is TRUE.

    Make sure you are calling session_start() before your script outputs anything to the browser.

    Check that apache has write access to the session path. Mine is /tmp