note 23046 deleted from ref.session by sniper

From: Date: Sun, 28 Jul 2002 00:49:06 +0000
Subject: note 23046 deleted from ref.session by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-33747@lists.php.net to get a copy of this message
After lots of headaches i finally found a way to pass session ID's without having to edit the URL, and letting PHP do it for me. For example, if i use a function to print links, i can append $SID instead of SID. When formatting the URL, PHP will tag on ? and & where necessary, incase i pass a URL with variables already. Take a look at the function below. /* make_link() Returns a link. */ function make_link($url, $text=false, $target=false, $extras=false) { return sprintf ( '<a href="%s"%s%s>%s</a>', $url.$SID, ($target ? ' target="'.$target.'"' : ''), ($extras ? ' '.$extras : ''), ($text ? $text : $url) ); } If i pass a URL for example, /index.php?var=value. PHP will tag on the SID and apply a & after value, ie. /index.php?var=value&session_id=<session id>. And if i just pass /index.php, PHP will tag on ?session_id=<session id>. I've been told this wont work (without the person even testing it), but it works fine for me, and takes less code if you were to format the string afterwards.

« previous php.notes (#33747) next »