Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    dva
    dva is offline
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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...

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,071
    Thanks
    11
    Thanked 96 Times in 94 Posts
    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)

  • #3
    Regular Coder
    Join Date
    Sep 2005
    Location
    Liverpool
    Posts
    226
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,071
    Thanks
    11
    Thanked 96 Times in 94 Posts
    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)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •