Jump to content

Session Not Being Stored Why?


lovephp

Recommended Posts

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 by lovephp
Link to comment
Share on other sites

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;        
   }
?>

Link to comment
Share on other sites

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>";

Link to comment
Share on other sites

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 by lovephp
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by PFMaBiSmAd
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.