CodeIgniter Forums

Full Version: {SOLVED} PHPSESSID on every link
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]cristian_c[/eluser]
I'm creating my church site with CI. The problem that I have is that the firt time I load a page into the browser, every link includes the PHPSESSID=. If I refresh the page then it is clean

before refresh: mydomain.org/whoweare?PHPSESSID=c5442df569bdd20ea80033625e8eafa8
after refresh: mydomain.org/whoweare

El Forum

[eluser]Michael Wales[/eluser]
Weird... definitely not something with CI by default.

I see that solved is in the title here - would you mind sharing your solution with everyone else, in case someone else comes across a similar issue?

El Forum

[eluser]cristian_c[/eluser]
the problem was that I din't put the base_url in my links. so the link was reading like this
Code:
<a href="whoweare"> bad
and not
Code:
<a href="&lt;?=base_url();?&gt;whoweare"> good

El Forum

[eluser]Alex007[/eluser]
I don't get it, not using baseurl() isn't supposed to automatically add a PHPSESSID to every link in your pages.

I don't use baseurl() at all (but my CI install it at the root of my htdocs) and I definitly don't have weird PHPSESSID appended to my urls...

It reall sounds like a config thing on your webserver. IIRC, PHP can be configured to append the session ID afetr ALL urls ()when cookies are not present), this is probably what's happening. Now why does it go away when you add baseurl() is even stranger.

El Forum

[eluser]cristian_c[/eluser]
Interesting,
I was trying diffent things, that is when I put the base_url and it fixed the problem.

El Forum

[eluser]jp.fox[/eluser]
I've solved the same problem with :

ini_set("session.use_only_cookies","on");
ini_set("session.use_trans_sid","off");

in a library loaded before generating content (ie : in Controller constructor)

Hope this helps