SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Wibblesticks Gryff's Avatar
    Join Date
    Oct 2001
    Location
    Asgard
    Posts
    442
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    getting vars back from sessions

    i've read the documentation on php.net and in my book and i still cant get this working properly
    my cookie ie = rds
    instead of the defualt PHPSESSID
    how do i get the variables
    session_start();
    session_register("result[0], result[4], result[5], result[6], result[7], result[8], result[9], result[10], result[11], result[12], result[13], result[14");

    back on another page?
    i tried $HTTP_SESSION_VARS[ " result[0] " ];
    but it doesnt appear to be working if i use
    echo( "$result[0]" );

    can anyone help? *looks at freddy *

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    All you gotta do is register the array not every element

    PHP Code:
    session_start();
    session_register("result");
    $result = array('blah1''blah2''blah3'); 

    ON next page this should be available to you.

    PHP Code:
    session_start();
    foreach(
    $result as $key => $val) {
        print 
    "$key = $val<br>";
        } 
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    Wibblesticks Gryff's Avatar
    Join Date
    Oct 2001
    Location
    Asgard
    Posts
    442
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    on the first page i have
    $sql = mysql_query("SELECT * FROM accounts WHERE username like '$userid'") or die(mysql_error());
    $result = mysql_fetch_array($sql);
    so $result is already an array

    i still dont get how to grab the variables on the next page

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You call session_start(); then access the variables, as in

    PHP Code:
    print $result['fieldname']; 
    Are you getting some kind of error? Have you looked in the session file to make sure the data is indeed being stored in it?
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    Wibblesticks Gryff's Avatar
    Join Date
    Oct 2001
    Location
    Asgard
    Posts
    442
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    got it working now freddy
    i didnt realise you needed to use session_start()
    on each page you wanted them to be able to access them with.


Bookmarks

Posting Permissions

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