欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

php 得到session id

shiping1 的头像

There are 2 ways to use sessions and session id's in PHP:

1 - Auto generate the session ID and get it:

session_start(); $id = session_id();

2 - Set the session ID manually and then start it:

session_id( 'mySessionId' ); session_start();

If you intend to set the session ID, you must set it before calling session_start(); If you intend to generate a random session_id (or continue one already started in a previous page request) and thenget that id for use elsewhere, you must call session_start() before attempting to use session_id() to retrieve the session ID.

来自 http://stackoverflow.com/questions/7068791/how-to-get-set-session-id-or-should-it-be-generated-autom...



session_start();    
echo session_id();

来自  http://stackoverflow.com/questions/21302733/how-can-i-get-session-id-in-php-and-show-it
普通分类: