my code is simple:
<?php
session_start();
session_regenerate_id();
?>
When the first time I request this page, the HTTP request with no cookie, then it will response with two 'set-cookie:PHPSESSID=xxxxxx' Then I thought that I may write code like this:
<?php
session_start();
if(!empty($_SERVER['HTTP_COOKIE'])){
session_regenerate_id();
}
?>
While then, whether my HTTP request with cookie: PHPSESSID=xxxxxx or not, it will responses with only one 'set-cookie:PHPSESSID=xxxxxx'
However, my solution is very awkward. Any professional PHPer can tell me, how to write a professional code to handle the problem which is the HTTP request may with cookie 'PHPSESSID' or without cookie 'PHPSESSID'.