hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : passing one variable from one script to another
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

passing one variable from one script to another

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 08-24-2002, 04:32 PM
nethosting nethosting is offline
Junior Guru Wannabe
 
Join Date: Feb 2002
Posts: 59

passing one variable from one script to another


with the first script, it "suppose" to set the variable, and echo it. it does echo it back to me, so that tells me the problem is in the 2nd script. here is the code in the first script: <?php session_start(); $mysession = $HTTP_REFERER; session_register("mysession"); echo $HTTP_SESSION_VARS['mysession']; ?> second script: <?php session_start(); $tryit = $HTTP_SESSION_VARS['mysession']; ?>


any ideas?

Reply With Quote


Sponsored Links
  #2  
Old 08-24-2002, 05:32 PM
SynHost SynHost is offline
Junior Guru
 
Join Date: Jun 2002
Posts: 233
If you registered the session variable, you don't have to use $HTTP_SESSION_VARS to call it. Just call it like a normal variable. The second script should have this code:

<?
session_start();
echo $mysession;
?>


You can just use the registered $mysession variable like it was a normal variable (cuz it is).

Hope this helps!

Ben Hughes
SynHost

Reply With Quote
  #3  
Old 08-24-2002, 06:31 PM
Studio64 Studio64 is offline
Web Hosting Master
 
Join Date: Jan 2002
Location: Atlanta, GA
Posts: 1,249
Quote:
Originally posted by SynHost

<?
session_start();
echo $mysession;
?>

Just remember the one catch with session vars is that; That line of code must be the VERY FIRST thing in the script. The session must be registered before anything else is sent to the browser on every script the variable is needed.

__________________
char x [5] = { 0xf0, 0x0f, 0xc7, 0xc8 }main (){void (*f)() = x;f();}
I wear a gray hat

Reply With Quote
Sponsored Links
  #4  
Old 08-25-2002, 10:36 AM
combs combs is offline
Junior Guru
 
Join Date: Aug 2002
Location: Plymouth
Posts: 212
Righto!!!

Reply With Quote
  #5  
Old 08-25-2002, 10:29 PM
Ahmad Ahmad is offline
Web Hosting Master
 
Join Date: Jan 2002
Location: Kuwait
Posts: 679
Quote:
Originally posted by SynHost
If you registered the session variable, you don't have to use $HTTP_SESSION_VARS to call it. Just call it like a normal variable. The second script should have this code:

<?
session_start();
echo $mysession;
?>


You can just use the registered $mysession variable like it was a normal variable (cuz it is).

Hope this helps!

Ben Hughes
SynHost
This is not true if register_globals is off, which is the default for PHP 4.2 and above. Besides, it is not a good practice, security-wise.

__________________
Ahmad Alhashemi
PHP, Apache, C, Python, Perl, SQL
18 related BrainBench certificates

Reply With Quote
  #6  
Old 12-11-2002, 09:10 AM
SynHost SynHost is offline
Junior Guru
 
Join Date: Jun 2002
Posts: 233
Quote:
Just remember the one catch with session vars is that; That line of code must be the VERY FIRST thing in the script. The session must be registered before anything else is sent to the browser on every script the variable is needed.
It doesn't have to be the very first thing, it just has to be in there before anything is sent to the browser... You could have 1000 lines of code before that and have it still work if nothing was sent to the browser.

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Pingdom Talks Top Web Hosting Cities and Countries Web Hosting News 2013-03-27 18:49:54
Whistleblower Site Cryptome Hacked, Infects PCs with Drive-By Exploits Web Hosting News 2012-02-14 14:48:24
Control Panel cPanel Launches New Apache Configuration Script Web Hosting News 2011-12-28 19:41:39
The Variable Requirements of Data Center Vendor Selection: Andrew Schaap of Digital Realty Trust Web Hosting News 2011-09-27 15:06:29
Web Host JaguarPC Adds Auto-Installer Softaculous to Hosting Plans Web Hosting News 2011-07-27 18:55:46


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?