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.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 10-26-2006, 11:05 PM   #1
infectd
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.
infectd is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-26-2006, 11:16 PM   #2
WWC
#1 Adult Content Provider
 
WWC's Avatar
 
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!

WWC is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-26-2006, 11:21 PM   #3
borked
Totally Borked
 
borked's Avatar
 
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>";
not sure if that's what you were after!
__________________

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
borked is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-26-2006, 11:24 PM   #4
mrkris
Confirmed User
 
Join Date: May 2005
Posts: 2,737
Quote:
Originally Posted by borked View Post
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>";
not sure if that's what you were after!
Why not just:

Code:
echo empty($_REQUEST[sid']) ? 'foo' : 'bar';
__________________

PHP-MySQL-Rails | ICQ: 342500546
mrkris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-26-2006, 11:48 PM   #5
borked
Totally Borked
 
borked's Avatar
 
Industry Role:
Join Date: Feb 2005
Posts: 6,284
Quote:
Originally Posted by mrkris View Post
Why not just:

Code:
echo empty($_REQUEST[sid']) ? 'foo' : 'bar';

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
borked is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-27-2006, 07:13 AM   #6
infectd
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
infectd is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-27-2006, 07:19 AM   #7
darksoul
Confirmed User
 
darksoul's Avatar
 
Join Date: Apr 2002
Location: /root/
Posts: 4,997
Code:
<a href="http://www.gotosite.com/?<?echo $_REQUEST['referralCode']; ?>">See the tour</a>
__________________
1337 5y54|)m1n: 157717888
BM-2cUBw4B2fgiYAfjkE7JvWaJMiUXD96n9tN
Cambooth
darksoul is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-27-2006, 07:24 AM   #8
borked
Totally Borked
 
borked's Avatar
 
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
borked is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-27-2006, 07:25 AM   #9
borked
Totally Borked
 
borked's Avatar
 
Industry Role:
Join Date: Feb 2005
Posts: 6,284
Quote:
Originally Posted by darksoul View Post
Code:
<a href="http://www.gotosite.com/?<?echo $_REQUEST['referralCode']; ?>">See the tour</a>
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
borked is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-27-2006, 11:54 AM   #10
infectd
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?
infectd is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-27-2006, 11:56 AM   #11
infectd
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.
infectd is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-27-2006, 11:58 AM   #12
borked
Totally Borked
 
borked's Avatar
 
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
borked is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-27-2006, 12:02 PM   #13
ForteCash
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!"
Link Exchanges & Traffic Trades www.penilefitness.com/links/
*ICQ: 63935693* $50 per trial with www.ForteCash.com
ForteCash is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-27-2006, 01:41 PM   #14
infectd
Confirmed User
 
Join Date: Dec 2002
Location: Canerda
Posts: 1,122
I get an error about modifying header information
infectd is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-27-2006, 01:54 PM   #15
infectd
Confirmed User
 
Join Date: Dec 2002
Location: Canerda
Posts: 1,122
I added <?php ob_start(); ?> to the top and its working for now.
infectd is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-27-2006, 02:03 PM   #16
borked
Totally Borked
 
borked's Avatar
 
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
borked is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-27-2006, 04:05 PM   #17
infectd
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
infectd is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-27-2006, 04:06 PM   #18
MaddCaz
Confirmed User
 
Join Date: Mar 2006
Location: Illinois
Posts: 9,483
this shit foe my KIDS!!!!!
MaddCaz is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-27-2006, 04:18 PM   #19
borked
Totally Borked
 
borked's Avatar
 
Industry Role:
Join Date: Feb 2005
Posts: 6,284
Quote:
Originally Posted by infectd View Post
I tried to add you on icq and im getting an error can you add me 208250960 Thanks
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
borked is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-27-2006, 04:35 PM   #20
infectd
Confirmed User
 
Join Date: Dec 2002
Location: Canerda
Posts: 1,122
I got it working, but want to say thanks
infectd is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-27-2006, 04:38 PM   #21
pornpf69
Too lazy to set a custom title
 
pornpf69's Avatar
 
Join Date: Jun 2004
Location: Brasil
Posts: 15,781
interesting thread....
pornpf69 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-27-2006, 05:06 PM   #22
Varius
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
Varius is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-28-2006, 01:38 AM   #23
borked
Totally Borked
 
borked's Avatar
 
Industry Role:
Join Date: Feb 2005
Posts: 6,284
Quote:
Originally Posted by Varius View Post
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..)
I didn't know that - great info, thx
__________________

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
borked is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-28-2006, 03:09 AM   #24
V_RocKs
Damn Right I Kiss Ass!
 
Industry Role:
Join Date: Dec 2003
Location: Cowtown, USA
Posts: 32,422
I like nerd fights...
V_RocKs is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.