![]() |
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. |
you post an ad in craigslist, you'll get 100 resumes :-)
|
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) { |
Quote:
Code:
echo empty($_REQUEST[sid']) ? 'foo' : 'bar'; |
Quote:
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.... |
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 |
Code:
<a href="http://www.gotosite.com/?<?echo $_REQUEST['referralCode']; ?>">See the tour</a> |
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: |
Quote:
|
So if I add that into the header of my site its just going to work?
|
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.
|
setcookie("referralCode", $_GET['referralCode'])
php.net is your friend ;) |
www.reecemarketing.com <---PHP Pro's :thumbsup
|
I get an error about modifying header information
|
I added <?php ob_start(); ?> to the top and its working for now.
|
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. |
I tried to add you on icq and im getting an error can you add me 208250960 Thanks
|
this shit foe my KIDS!!!!!
|
Quote:
|
I got it working, but want to say thanks
|
interesting thread....
|
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..) |
Quote:
|
I like nerd fights...
|
| All times are GMT -7. The time now is 03:56 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123