PDA

View Full Version : Changing how session looks


Nightfire
10-14-2002, 02:12 AM
I've tried everything I can think of to do this in the URL

page.php?sess=<?=SID?>
page.php?sess=<?=$PHPSESSID?>

When I first get to the page, the URL shows

page.php?sess=&PHPSESSID=dfgdfksdlfksdfs

but when I go to page 2, the url changes to how I want it,

page2.php?sess=dsfsdfdsfkjsd

How can I do this so it's automatic, like on these forums

<edit>
I've got an example online now so you can see what I mean. IF you click on a page, the URL is http://wcreations.co.uk/Testing/?action=details&s=&PHPSESSID=ca10a7f320b78d94385e83f8fbcea30b12 but if you go to another page, the URL behaves itself and goes to how I want http://wcreations.co.uk/Testing/?action=details&s=ca10a7f320b78d94385e83f8fbcea30b12

Here's the URL for you to look yourself if you need it still http://wcreations.co.uk/Testing
</edit>

Ökii
10-15-2002, 02:20 PM
You could start the session on a subpage and redirect. Working on from that you could run a test at the top of all pages and redir to the subpage prior to header info being added....

fly typed guesswork code

if(strpos($HTTP_REFERER,'wcreations.co.uk')!>4) {
header("location: setsession.php");
}

setsession.php...

session_start();
header("location: $HTTP_REFERER");

The snag seems to be that the first page that generates the session automatically appends it to the url as PHPSESSID= SID= or whatever other form it uses. The above techniques simply tries to assure that the only page that initially sets the session is setsession.php

Nightfire
10-23-2002, 01:35 PM
I used the basics of your script. This how how I used it

if(!($s)){
require("setsession.php");
}

in setsession

session_start();
header("location:?action=$action&s=$PHPSESSID");


It works perfectly :) Thanks