KBD

Keith Devens .com

Saturday, July 5, 2008 Flag waving
Fools ignore complexity. Pragmatists suffer it. Some can avoid it. Geniuses remove it.... – Alan Perlis
← Entry 1345Entry 1347 →

Daily link icon Saturday, February 2, 2002

Entry 1346

Quick PHP tip. I've seen lots of people run into this: if you're using PHP sessions, depending on how your copy of PHP is configured you'll get URLs that look like this: "http://domain.com/?PHPSESSID=1bf25e86558f71d0cab893a2ecdd7327". This is PHP doing URL-rewriting for you to propagate the session id.

To turn it off use the following line at the top of your script:
ini_set("session.use_trans_sid", "0");

You'll typically get URLs like that the first time you go to a site, and then when you start clicking on links it goes away. The reason is that the first time you go to the site, PHP creates a session. However, since your browser didn't send back a cookie containing the session id for that request, PHP doesn't know whether your browser has cookies turned off or whether it's just the first time you're coming to the site. So if you're configured to do url-rewriting, PHP does the "safe" thing and rewrites your urls so that the session id gets propagated.

The next page you go to on the site, your browser will send the cookie back to the server, and PHP will realize that your browser is using cookies to pass the session id, so it will stop rewriting your URLs, and everything will look normal.

← Entry 1345Entry 1347 →

Comments XML gif


Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

July 2008
SunMonTueWedThuFriSat
 12345
6789101112
13141516171819
20212223242526
2728293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 5 posts

Recent comments XML

Girls, please don't get breast implants

> And no, you will not be receiving​a picture.

:-(...

Keith: Jul 2, 6:05am

Javascript clone function

This is a clever way to clone an​object if you are using YAHOO UI.​Same tec...

Antonio: Jul 1, 12:47pm

I hate Norton Antivirus

Oh just one other thing norton is​great at keeping people out of your​compu...

kevin.sands: Jul 1, 12:50am

Terminator 3 was awful

I think the biggest reason why T3​totally blew was because Edward​Furlong g...

76.167.172.64: Jun 29, 3:06am

Generated in about 0.101s.

(Used 8 db queries)

mobile phone