Hi mates,

I have a php page called "get_http_vars.php" that's hidden and not browsed in browser and only used to receive HTTP GET response variables from remote server. The

problem the value of $_SESSION is empty when the HTTP GET variables are received (I mean when the page gets response from the remote server). I noticed that when

I browse the page in browser like: http://localhost/get_http_vars.php, then $_SESSION will get its value.

Now please can you advise, how can I get the $_SESSION value in this page? Is there any way to pass it's value to the page where it's hidden and non browsed?

Please see the code below.

Thanks.

<?php
session_start();
$id =  $_SESSION['id'];  // $_SESSION['id']  is empty.

//=========== GET variables from remote server=================
if (isset($_GET['var1']))
     $var1 = trim($_GET['var1']);
     
if (isset($_GET['var2']))
     $var2 = trim($_GET['var2']);
         
if (isset($_GET['var3']))
     $var3 = trim($_GET['var3']);

?>

Recommended Answers

All 9 Replies

if your session initialization is not in get_http_vars.php, then your can get then session in any page.
First of all check the session is set or not.

if your session initialization is not in get_http_vars.php, then your can get then session in any page.
First of all check the session is set or not.

I have included session_start() at the beginning of the page. All viewable php pages are working OK, but this page is not.

Thanks.

in which page the session is initialized(passing a value).

I am not new to PHP, there is session class that gets the session value man, I just included example of the page that is not viewable and this is the reason I think, the session will never get its value without refreshing the page.

<?php
session_start();
require_once('sesssion.class.php');
$id =  $_SESSION['id'];  // $_SESSION['id']  is empty.
 
//=========== GET variables from remote server=================
if (isset($_GET['var1']))
     $var1 = trim($_GET['var1']);
 
if (isset($_GET['var2']))
     $var2 = trim($_GET['var2']);
 
if (isset($_GET['var3']))
     $var3 = trim($_GET['var3']);
 
?>

i tried with one example.
check this:

session.php

<?php 
session_start();
if(!isset($_SESSION['id']))
$_SESSION['id']=90;
?>

test2.php

<?php
session_start();
require_once('session.php');
$id =  $_SESSION['id'];  // $_SESSION['id']  is empty.
 
//=========== GET variables from remote server=================
if (isset($_GET['var1']))
     $var1 = trim($_GET['var1']);
 
if (isset($_GET['var2']))
     $var2 = trim($_GET['var2']);
 
if (isset($_GET['var3']))
     $var3 = trim($_GET['var3']);
 
     header('Location: test1.php?id='.$id);
?>

test1.php

<?php 
echo $_GET['id'];

browse test2.php in your browser.
thanks.

i tried with one example.
check this:

session.php

<?php 
session_start();
if(!isset($_SESSION['id']))
$_SESSION['id']=90;
?>

test2.php

<?php
session_start();
require_once('session.php');
$id =  $_SESSION['id'];  // $_SESSION['id']  is empty.
 
//=========== GET variables from remote server=================
if (isset($_GET['var1']))
     $var1 = trim($_GET['var1']);
 
if (isset($_GET['var2']))
     $var2 = trim($_GET['var2']);
 
if (isset($_GET['var3']))
     $var3 = trim($_GET['var3']);
 
     header('Location: test1.php?id='.$id);
?>

test1.php

<?php 
echo $_GET['id'];

browse test2.php in your browser.
thanks.

Sorry, you are not providing any solution!! I told you, I do not want to browse test2.php!!

ok then sorry

ok then sorry

If you do not know how to solve the issue, then no need to participate and waste my thread as visitors will think it's solved when they see your contribution, I mentioned in the beginning that I do not want to refresh the callback.php and you insist to refresh it!!

Please mates suggest something... Till now I am unable to find solution!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.