Forum Moderators: coopster

Message Too Old, No Replies

Session without cookie

doesn't work!

         

tata668

5:48 pm on May 14, 2005 (gmt 0)

10+ Year Member



I'm trying to enable the session management without using cookie.
In my php.ini I have:

session.use_cookies = 1
session.use_only_cookies = 0
session.use_trans_sid = 1
session.name = PHPSESSID

I call session_start() on each page.

I turn off the cookies in my browser and browse my site. The session doesn't work and no "PHPSESSID" appears in any URL!

Any idea?

mcavic

8:18 pm on May 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've never used sessions without cookies. But don't you have to build the session variable into the URLs yourself?

Here's a snippet from the PHP manual. See the last line.

// page1.php

session_start();

echo 'Welcome to page #1';

$_SESSION['favcolor'] = 'green';
$_SESSION['animal'] = 'cat';
$_SESSION['time'] = time();

// Works if session cookie was accepted
echo '<br /><a href="page2.php">page 2</a>';

// Or maybe pass along the session id, if needed
echo '<br /><a href="page2.php?' . SID . '">page 2</a>';

tata668

8:37 pm on May 14, 2005 (gmt 0)

10+ Year Member



Yes I know I can append the SID to each of my links but I would like to understand why it doesn't work automatically, as it is supposed to with my configuration! Thanks for the help anyway..

coopster

8:54 pm on May 14, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Are you certain that --enable-trans-sid is compiled into your configuration? Also, did you remember to restart Apache after modifying the php.ini?

tata668

9:02 pm on May 14, 2005 (gmt 0)

10+ Year Member



Should I be able to see soemthing about "trans_sid" on a phpinfo page if apache is compiled with the right flag? Because I see nothing. But I stopped Apache and restarted it and it still doesn't work.

I'm working on Windows and I have used the default apache installation.

mcavic

9:52 pm on May 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I stand corrected:

PHP is capable of transforming links transparently. Unless you are using PHP 4.2 or later, you need to enable it manually when building PHP. Under Unix, pass --enable-trans-sid to configure. If this build option and the run-time option session.use_trans_sid are enabled, relative URIs will be changed to contain the session id automatically.

[us2.php.net...]

Yes, I happen to have --enable-trans-sid shown in phpinfo() under the configure command. But I'm also on PHP 4.3.

tata668

10:24 pm on May 14, 2005 (gmt 0)

10+ Year Member



I'm also with 4.3.10

And finally I found that in my phpinfo():

session.use_trans_sid On On

So I guess PHP is properly compiled to use that feature.. But it doesn't work! :-(

petachok

7:34 pm on May 16, 2005 (gmt 0)

10+ Year Member



I'm having exactly the same problem and haven't found a solution. I gave up on it though, since I found many articles saying that passing SID throuhg URLs is not secure. So too bad for the users that don't use cookies. :P

tata668

7:55 pm on May 16, 2005 (gmt 0)

10+ Year Member




I'm having exactly the same problem and haven't found a solution. I gave up on it though, since I found many articles saying that passing SID throuhg URLs is not secure. So too bad for the users that don't use cookies. :P

Haha, I also gave up! ;-)

Users will have to have their cookies enabled exept for some pages. But I'm providing a site map that can be browsed without cookies and that give access to all the content... I hope the search engines will be happy with it!

I'm still curious about the problem though. Is it a problem on Windows only?
At least I'm not the only one for whom it doesn't work!