lovephp Posted October 5, 2012 Share Posted October 5, 2012 (edited) ok i got this link which sends a id something like page.php?cid=prg1234 now on my form page i got $cid = $_REQUEST['cid']; $_SESSION['cid'] = $cid ; on the url i do see the link like form.php?cid=prg1234 but when i print session i get not value? print_r($_SESSION['cid']); this hows nothing. Edited October 5, 2012 by lovephp Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 5, 2012 Share Posted October 5, 2012 Did you start the session using session_start? Post more of the relevant code (not the whole file please) Quote Link to comment Share on other sites More sharing options...
lovephp Posted October 5, 2012 Author Share Posted October 5, 2012 here see <?php session_start(); include ("functions.php"); include ("config.php"); $cid = $_REQUEST['cid']; $cid = $_SESSION['cid']; print_r($_SESSION); /////////////////////////spam check//////////////////////////// function encode_str($input){ for ($i = 0; $i < strlen($input); $i++) { $output .= "".ord($input[$i]).';'; } return $output; } function dutyGuard(){ $first_number=mt_rand(1, 94); $second_number=mt_rand(1, 5); $_SESSION["dutyGuard"]=($first_number+$second_number); $operation=" <b>".encode_str($first_number ." + ". $second_number)."</b> ?"; echo "What's ".$operation; } ?> Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 5, 2012 Share Posted October 5, 2012 $cid = $_REQUEST['cid']; $cid = $_SESSION['cid']; Is your code. $cid = $_REQUEST['cid']; $_SESSION['cid'] = $cid ; Is what you SAID your code is. See the difference? Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted October 5, 2012 Share Posted October 5, 2012 $a = $b is not the same as $b = $a. Your initial post says you have: $_SESSION['cid'] = $cid; That is not what your code has. Quote Link to comment Share on other sites More sharing options...
lovephp Posted October 5, 2012 Author Share Posted October 5, 2012 i know in my first comment i wrote $_SESSION['cid'] = $cid; and this is something $cid = $_SESSION['cid']; i was trying to see if it works none is working Quote Link to comment Share on other sites More sharing options...
scootstah Posted October 5, 2012 Share Posted October 5, 2012 What does the following give you? <?php session_start(); include ("functions.php"); include ("config.php"); $cid = $_REQUEST['cid']; $_SESSION['cid'] = $cid; echo "<pre>Request:\n\n" . print_r($_REQUEST, true) . "</pre>"; echo "<pre>Session:\n\n" . print_r($_SESSION, true) . "</pre>"; Quote Link to comment Share on other sites More sharing options...
lovephp Posted October 5, 2012 Author Share Posted October 5, 2012 (edited) i get code] Array ( [phpSESSID] => f5d20dedfeb5004268f8c3e4d7740d21 [cprelogin] => no [cpsession] => n:eQi2Pjk3ipO9_fAcppx_Iln7dyxnPzrMmsbKVmV6QuDZvMR0dIRoOPXFCdVfxAvH [langedit] => [lang] => [__utma] => 133155729.404469517.1349470259.1349470259.1349470259.1 [__utmc] => 133155729 [__utmz] => 133155729.1349470259.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none) [__atuvc] => 11|40)Session:Array( [cid ] => [dutyGuard] => 52 [cid] =>)[/code] Edited October 5, 2012 by lovephp Quote Link to comment Share on other sites More sharing options...
scootstah Posted October 5, 2012 Share Posted October 5, 2012 So, as you can see, the "cid" index does not exist in $_REQUEST. Quote Link to comment Share on other sites More sharing options...
lovephp Posted October 5, 2012 Author Share Posted October 5, 2012 so how can i make it to exist in $_REQUEST? Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 5, 2012 Share Posted October 5, 2012 Post the actual URL you go to on the page that creates that output. Is this file being included somehow? Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted October 5, 2012 Share Posted October 5, 2012 (edited) Is it in the URL? Are you positive? PHP says it's not in the URL. Jess, get some work done! Stop posting what I'm posting 10 seconds before me Edited October 5, 2012 by ManiacDan Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 5, 2012 Share Posted October 5, 2012 You stop stalking me!! I am working. I'm multitasking. It's this amazing thing we women can do. Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted October 5, 2012 Share Posted October 5, 2012 You do other amazing things, like steal my posts before I'm done writing them. Quote Link to comment Share on other sites More sharing options...
lovephp Posted October 5, 2012 Author Share Posted October 5, 2012 ok well let so clear again on my friends website i put a link like <a href="mysite.com/form.php?cid=prg1234">My form</a> the cid im using as to keep track that user with that cid is coming from my friend site.and yes cid comes from the URL Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted October 5, 2012 Share Posted October 5, 2012 So the URL bar in the browser says: http://www.mysite.com/form.php?cid=prg1234 And inside form.php you have the print_r code you got earlier? And 'cid' is not in $_REQUEST? Is all of that true? Quote Link to comment Share on other sites More sharing options...
lovephp Posted October 5, 2012 Author Share Posted October 5, 2012 yes very true. the moment i come from the link in print_r(); i do get to see the cid like cid=>prg1234 but now say i remove the cid=prg1234 http://www.mysite.com/form.php and refresh the page the print_r(); will not longer show cid=>prg1234 for its not getting stored in session at all Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted October 5, 2012 Share Posted October 5, 2012 So when you go to the site without cid in the URL, cid isn't in the URL and then you overwrite the session. That's the actual problem: You're visiting the page AGAIN without cid and your code doesn't say "don't do this if cid doesn't exist." You're developing without error_reporting turned on. If you had your errors turned on, you would have gotten a warning hours ago that would have prevented this whole conversation. if ( isset($_GET['cid']) ) { $_SESSION['cid'] = $_GET['cid']l } There, done. Quote Link to comment Share on other sites More sharing options...
lovephp Posted October 5, 2012 Author Share Posted October 5, 2012 omg yes i had error reporting turned off ;-) thanks soo much for helping me fix it. cheers \m/ Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 5, 2012 Share Posted October 5, 2012 (edited) Any chance you have a cookie named 'cid' that is overriding the get 'cid' value, since $_REQUEST combines get, post, and cookie (in that order, by default.) edit: never mind, the forum's lack of real post notification strikes again. Edited October 5, 2012 by PFMaBiSmAd Quote Link to comment Share on other sites More sharing options...
Christian F. Posted October 5, 2012 Share Posted October 5, 2012 (edited) Try adding var_dump ($_SERVER['REQUEST_URI']); to the code as well, and post what it says. Edit: You don't say, PFMaBi... Edited October 5, 2012 by Christian F. Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted October 5, 2012 Share Posted October 5, 2012 edit: never mind, the forum's lack of real post notification strikes again. It seems to be on a 2-3 minute delay. I've been inadvertently stalking Jess all morning. Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 5, 2012 Share Posted October 5, 2012 Psh inadvertant. Stalker. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.