PHP session_id () null

I'm having difficulty with sessions.

On my local MAMP test server, if yes:

session_start (); echo session_id ();

I get a pretty session id.

If, however, the same thing on my web server, all I can get from session_id is "null". Testing the return from session_start () and using sessions all work, but session_id () $ SID and $ PHPSESSID are null.

Is this hidden for extra security? I want to allow flash to make changes to the shopping cart through PHP calls and display the shopping cart (which is stored in the session) using a browser.

+4
source share
2 answers

Verify that the return value of session_start () is TRUE.

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

Make sure apache has write access to the session path. Mine is / tmp

+4
source

I had a similar problem ( session_id() return "" , hope this is related to your question). I closed all the relevant tabs and deleted all the relevant cookies, and then re-opened the site and now session_id() returns a beautiful hash value.

+1
source

Source: https://habr.com/ru/post/1332970/


All Articles