Jump to content

Remove session ID's from string


Mcod

Recommended Posts

I am looking for a way to remove session id strings from URL's. As far as I know, they always have the same size and pattern like:

 

http://www.domain.com/forumdisplay.php?s=3d496add17bf8a05551109b5693e9489&f=33

 

http://www.domain.com/forumdisplay.php?s=3d496add17bf8a05jd7shdbe383e9489&f=21

 

So my mission is removing the part where it says s=sessionid which is always different. What I try to return would be:

 

http://www.domain.com/forumdisplay.php?&f=33

and

http://www.domain.com/forumdisplay.php?f=21

 

As you can see, I also need to remove the & at the end of the string, so it doesn't say http://www.domain.com/forumdisplay.php?&f=33 as the & would be too much. Now here is another issue... sometimes the session has a different name - for example sessid= or session= which I would also like to cover if possible.

 

Your help is greatly appreciated as usual :)

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

Hey Mcod,

 

Try this.

Should work with s, sessid, sessionid.

 

$pattern=',php\?\Ks(?:ession|essid)?=[^&]*&,';
$s = 'http://www.domain.com/forumdisplay.php?s=3d496add17bf8a05551109b5693e9489&f=33';
$s = preg_replace($pattern,"",$s);
echo $s;

 

:)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.