Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2002
    Location
    United Kingdom
    Posts
    1,236

    Unhappy sessions help please

    Ok i have got a problem.
    I want to use php4 sessions
    and i have the book beginning php4
    but it doesn't tell you how to use sessions very well.

    So, if i got a form, on say test.php which asks then user to type anything and it puts it into a varialbe called $example and then moves to test2.php

    how would i store the $example variable from the form on tast.php into a new session???

    also, say for example, i then had a link on test2.php that moves the user to test3.php, how do i get the data back from the session and display the data from the form, on the screen using echo()???

    if someone could explain this to me, then that would be great.

    thanx allot

    Matt

  2. #2
    Join Date
    Aug 2002
    Location
    London, UK
    Posts
    9,037
    there are loads and loads of sessions examples.. type "php sessions tutorial" into google, thats how i learnt.
    Matt Wallis
    United Communications Limited
    High Performance Shared & Reseller | Managed VPS Cloud | Managed Dedicated
    UK www.unitedhosting.co.uk | US www.unitedhosting.com | Since 1998.

  3. #3
    Join Date
    Aug 2002
    Location
    Minnesota
    Posts
    10
    PHP Code:
    <?
           session_start
    ();

           if(
    session_is_registered('password'))
           {

                  
    // Session Already Registered Display Content
     
           
    } else {

               
    // Register Session
               
    if(!$example)
               {
                   
    // Example Doesn't Exist
               
    }
                elseif(
    $example == "password")
               {
               
                   
    // Example = Password Register Session Variables
                   
    $password $example;
                   
    session_register('password');
                   print 
    "<A HREF=''>Click Here</A> to continue!";

               }
           }
    ?>

  4. #4
    Join Date
    Oct 2002
    Posts
    250
    I think the preceeding code assumes that you register_globals on. Real hot topic in the PHP world about this, and the php guide reccomends that you turn them off.

    With register globals off, you'll want to access session variables via $_SESSION["varname"] array instead.

    There is a thread very similar to this here: http://www.webhostingtalk.com/showth...threadid=80876

    Also, go to http://www.php.net, for a discussion on register_globals, session variables and comments from php developers using the tool.

    Bob

Posting Permissions

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