Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-05-2006, 03:04 PM   PM User | #1
dva
New to the CF scene

 
Join Date: Jan 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
dva is an unknown quantity at this point
trouble with Register_Global function with the newest PHP versions

Hello,
I`m new around here and having a problem with the new hosting companies that have installed the newest versions of the PHP.
the register_global settings it`s turrned off ( disabled ) as default and my web script it`s based on register_global enabled

The session start script shows like this :


session_start();
if(isset($_POST['set']) && $_POST['set']=="login"){
header("Cache-control: private");
session_register("mail");
session_register("pase");
$mail=$_POST['mail'];
$pase=$_POST['pass'];
}elseif(isset($_GET['logout']) && $_GET['logout']=="user"){
session_unregister("mail");
session_unregister("pase");
session_destroy();


How can I modify it so I can make it work with register_global disabled ? Or at least another option...
dva is offline   Reply With Quote
Old 01-05-2006, 04:58 PM   PM User | #2
firepages
Super Moderator


 
Join Date: May 2002
Location: Perth Australia
Posts: 3,904
Thanks: 5
Thanked 79 Times in 78 Posts
firepages will become famous soon enough
register_globals=on
session_register("name");
$name='blah';
register_globals=off
$_SESSION['name'] = 'blah';

to get the values echo $_SESSION['name']; etc

PS this is the SNIPPETS forum , moving you to regular PHP
__________________
resistance is...

MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
firepages is offline   Reply With Quote
Old 01-05-2006, 07:43 PM   PM User | #3
Rich Pedley
Regular Coder

 
Join Date: Sep 2005
Location: Liverpool
Posts: 226
Thanks: 0
Thanked 0 Times in 0 Posts
Rich Pedley is an unknown quantity at this point
and if I am correct:
Code:
$_SESSION['name'] = 'blah';
can be used in either case and is therefore the best one to use.
__________________
my mind is on a permanent tangent
Rich Pedley is offline   Reply With Quote
Old 01-06-2006, 02:51 AM   PM User | #4
firepages
Super Moderator


 
Join Date: May 2002
Location: Perth Australia
Posts: 3,904
Thanks: 5
Thanked 79 Times in 78 Posts
firepages will become famous soon enough
sorry yes, if PHP > = 4.1 (or is it 4.0.1?) then you should use $_SESSION regardless of register_globals if you want your scripts more secure.
__________________
resistance is...

MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
firepages is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:50 PM.


Advertisement
Log in to turn off these ads.