|
|
|
||||
|
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() |
|
|||||||
| Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
|
Thread Tools |
|
|
#1 |
|
Confirmed User
Join Date: Dec 2002
Location: Canerda
Posts: 1,122
|
PHP Help - Easy but not for me.
I need to capture a session variable from a URL. This is so basic its embarassing.
"In addition to capturing the referralCode and retaining it as a session variable, you will also need to include logic in your download link as: IF sessionVar ?referralCode? NOT null THEN DownloadLink = http://www.myurlhere.com?referralCode=<referralCode> ELSE DownloadLink = http://www.myurlhere.com (or, you could go with another referralCode - a generic one" What I've been reading is that I need to set a cookie and then drop some php. Any help here? Even if you send me to a working exmaple code I can figure it out. |
|
|
|
|
|
#2 |
|
#1 Adult Content Provider
Join Date: Jul 2003
Location: Glendale, Ca
Posts: 11,577
|
you post an ad in craigslist, you'll get 100 resumes :-)
__________________
[email protected] ICQ : 494-353-230 Follow WWC on Twitter CLICK HERE! " CONTENT PROVIDER OF THE YEAR! " ~ 2007 , 2008 & 2009 XBIZ AWARDS WINNER! .......www.WorldWideContent.com / www.WorldWideFeeds.com......
|
|
|
|
|
|
#3 |
|
Totally Borked
Industry Role:
Join Date: Feb 2005
Posts: 6,284
|
it depends how the session id is passed in the URL...
eg index.php?sid=<sessionid> then your session variable name is 'sid' I'm guessing the session id is the 'referralCode', in which case: Code:
function check_sess($sid, $refCode) {
if ($sid) {
if($sid == $refCode) return TRUE;
else return FALSE;
}else return FALSE;
}
// check session and give link
if(check_sess($_GET['sid'])) print"<referral code link here>";
else print"<non-referred link>";
__________________
![]() For coding work - hit me up on andy // borkedcoder // com (consider figuring out the email as test #1) All models are wrong, but some are useful. George E.P. Box. p202 |
|
|
|
|
|
#4 | |
|
Confirmed User
Join Date: May 2005
Posts: 2,737
|
Quote:
Code:
echo empty($_REQUEST[sid']) ? 'foo' : 'bar'; |
|
|
|
|
|
|
#5 |
|
Totally Borked
Industry Role:
Join Date: Feb 2005
Posts: 6,284
|
because I was under the impression that the refCode was the session id, and so the function gave more flexability as to what to do with it....
__________________
![]() For coding work - hit me up on andy // borkedcoder // com (consider figuring out the email as test #1) All models are wrong, but some are useful. George E.P. Box. p202 |
|
|
|
|
|
#6 |
|
Confirmed User
Join Date: Dec 2002
Location: Canerda
Posts: 1,122
|
hmm I know the end of my urls im sending out have ?referralCode=XXXX
where XXXX being unique ID's so it has to read from the url they come in on and keep it while they browse around until they hit the download link. So I dont think the code above will work per say.. like that one is checking to see if they have refcode in their link.. I may be wrong too and it might be what I need haha :P |
|
|
|
|
|
#8 |
|
Totally Borked
Industry Role:
Join Date: Feb 2005
Posts: 6,284
|
ah - so the surfer comes in with referralCode=xxxx and you want to send them out with the same?
Then, yup, store the referral code in a session cookie and collect it on the way out.... Code:
coming in:
if(!empty($_GET['referralCode'])) setcookie("referralCode", $_GET['referralCode']);
goin out:
if(isset($_COOKIE['referralCode'])) print"<a href=\"http://somedomain.com/index.php?referralCode=".$_COOKIE['referralCode']."\">Now click away</a>";
else print"<a href=\"http://somedomain.com/index.php\">Now click away</a>";
__________________
![]() For coding work - hit me up on andy // borkedcoder // com (consider figuring out the email as test #1) All models are wrong, but some are useful. George E.P. Box. p202 |
|
|
|
|
|
#9 |
|
Totally Borked
Industry Role:
Join Date: Feb 2005
Posts: 6,284
|
he needs to keep the refCode while the surfer surfs around his site. Cookie it, or he'll have to pass the blasted thing around as a getvar on every internal link....
__________________
![]() For coding work - hit me up on andy // borkedcoder // com (consider figuring out the email as test #1) All models are wrong, but some are useful. George E.P. Box. p202 |
|
|
|
|
|
#10 |
|
Confirmed User
Join Date: Dec 2002
Location: Canerda
Posts: 1,122
|
So if I add that into the header of my site its just going to work?
|
|
|
|
|
|
#11 |
|
Confirmed User
Join Date: Dec 2002
Location: Canerda
Posts: 1,122
|
it prints a link for them, I need it to attach to a download link.. oh no it will work but I duno how to set a cookie.
|
|
|
|
|
|
#12 |
|
Totally Borked
Industry Role:
Join Date: Feb 2005
Posts: 6,284
|
setcookie("referralCode", $_GET['referralCode'])
php.net is your friend ;)
__________________
![]() For coding work - hit me up on andy // borkedcoder // com (consider figuring out the email as test #1) All models are wrong, but some are useful. George E.P. Box. p202 |
|
|
|
|
|
#13 |
|
Confirmed User
Join Date: Feb 2006
Location: Kansas City, Missouri
Posts: 3,278
|
www.reecemarketing.com <---PHP Pro's
__________________
![]() NO PILLS - NO EXPENSIVE STRETCHERS - JUST REAL EXERCISES THAT WORK! "Upsell Your Members The Top Penis Enlargement Site!" *ICQ: 63935693* $50 per trial with www.ForteCash.com |
|
|
|
|
|
#14 |
|
Confirmed User
Join Date: Dec 2002
Location: Canerda
Posts: 1,122
|
I get an error about modifying header information
|
|
|
|
|
|
#15 |
|
Confirmed User
Join Date: Dec 2002
Location: Canerda
Posts: 1,122
|
I added <?php ob_start(); ?> to the top and its working for now.
|
|
|
|
|
|
#16 |
|
Totally Borked
Industry Role:
Join Date: Feb 2005
Posts: 6,284
|
add the set cookie before ANY header information is sent, ie the very first thing on the page, before <html>
Or, like you found, suppress headers being sent by putting everything in an output buffer. This is all very basic stuff, like you know, and it's great you're taking your first steps to programming, but when things get a bit too much, don't be afraid to pay someone for help... we don't cost a lot. Good luck and continuation.
__________________
![]() For coding work - hit me up on andy // borkedcoder // com (consider figuring out the email as test #1) All models are wrong, but some are useful. George E.P. Box. p202 |
|
|
|
|
|
#17 |
|
Confirmed User
Join Date: Dec 2002
Location: Canerda
Posts: 1,122
|
I tried to add you on icq and im getting an error can you add me 208250960 Thanks
|
|
|
|
|
|
#18 |
|
Confirmed User
Join Date: Mar 2006
Location: Illinois
Posts: 9,483
|
this shit foe my KIDS!!!!!
__________________
![]() BigCocks.com - MatureWomen.com - Tranny.com - DrunkGirls.com - TeenGirls.com - MonsterCock.com and many more... Click here to see them all! |
|
|
|
|
|
#19 |
|
Totally Borked
Industry Role:
Join Date: Feb 2005
Posts: 6,284
|
sent you a message - off for zzzzzs
__________________
![]() For coding work - hit me up on andy // borkedcoder // com (consider figuring out the email as test #1) All models are wrong, but some are useful. George E.P. Box. p202 |
|
|
|
|
|
#20 |
|
Confirmed User
Join Date: Dec 2002
Location: Canerda
Posts: 1,122
|
I got it working, but want to say thanks
|
|
|
|
|
|
#21 |
|
Too lazy to set a custom title
Join Date: Jun 2004
Location: Brasil
Posts: 15,781
|
interesting thread....
__________________
|
|
|
|
|
|
#22 |
|
Confirmed User
Industry Role:
Join Date: Jun 2004
Location: New York, NY
Posts: 6,890
|
Just an FYI,
If you prefer a non-cookie approach you can also modify your php.ini to enable trans_sid (transparent session id), and then it will automatically append your session id to all urls (unless those called by javascript, which you'll still have to add manually - or forms, etc..)
__________________
Skype variuscr - Email varius AT gmail |
|
|
|
|
|
#23 | |
|
Totally Borked
Industry Role:
Join Date: Feb 2005
Posts: 6,284
|
Quote:
__________________
![]() For coding work - hit me up on andy // borkedcoder // com (consider figuring out the email as test #1) All models are wrong, but some are useful. George E.P. Box. p202 |
|
|
|
|
|
|
#24 |
|
Damn Right I Kiss Ass!
Industry Role:
Join Date: Dec 2003
Location: Cowtown, USA
Posts: 32,422
|
I like nerd fights...
|
|
|
|