Jump to content

Remove PHPSESSID from URL


rkelsey

Recommended Posts

I'm trying too make this website for a client (http://300seconds.freehostia.com/).

 

The problem is the PHPSESSID comes up the first time a user clicks a link. After that it disapears.

 

My website does use sessions to store user login information. I'm relatively new to PHP so can you try and explain as you go along?

 

Much apreciated! :)

Link to comment
https://forums.phpfreaks.com/topic/38758-remove-phpsessid-from-url/
Share on other sites

The problem is a common one. A session cookie doesn't get picked up until a refresh or a redirect, so setting a cookie on page A, needs to go to page B or refresh page A, in order to set the cookie. So your software or PHP config (trans_id) is setting the url session until the cookie gets set. There are ways around this, but that has to do with controlling the complete session process and defining a user login as apposed to just a visitor using the site! But the key is controlling the session and not using the core PHP session handler.

 

 

I think i get what you mean, all accept the last bit:

the key is controlling the session and not using the core PHP session handler.

 

Otherwise, i dont mind the PHPSESSID being there, but maybe i can do something like this in my .htaccess file:

RewriteRule ^site/(.*)/(.*)\.htm index.php?PHPSESSID=$1&page=$2

 

in which case i'd like to keep the PHPSESSID there always. I just dont want the PHPSESSID to be appended after the ".htm" really, because A) it spoils the "illusion" and B) it doesn't look that great.

 

If I wanted to keep it there always, how would I do that?

 

(Ideally, how do I hide it from the URL though?)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.