I want to be able to have users use a site with cookies disabled, but it needs sessions. So I have been going over all of the session info in the manual trying to figure out how I add the session ID to the url when cookies are disabled.
This is what I have:
<?php
ini_set('session.use_trans_sid', '1');
session_start();
print session_id();
?>
It is my understanding that now when I click a link, the session id should be added to the URL. However, that does not happen, and the session_id is changed.
Also, if I refresh the page, a new session starts, with a new ID. None of my session data is being saved. For example if I have this:
<?php
if(isset($_SESSION['test'])){
print $_SESSION['test'];
}else{
$_SESSION['test'] = 'test';
}
?>
The first time it should show nothing, and the second time (refresh) it should show 'test'. It always shows nothing.
Can anyone help me figure out how to accomplish this? I don't want to force users to enable cookies, but I don't want the session id in the URL unless it has to be.