Results 1 to 4 of 4

Thread: How to pass session value across pages?

  1. #1
    Join Date
    Aug 2007
    Location
    Malaysia
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to pass session value across pages?

    Hi..anybody.I am newbie here and have a form which have to pass through other pages and display on that page.How can I achieved it?

    For the first page,here is the script for session value:
    PHP Code:
     <?php
        session_start
    ();
        for (
    $i 1$i <= 3$i++) {
        
    $_SESSION['selected'][$i] = date('D d\t\h M'strtotime('+' $i ' days'));
        echo 
    '<option>' $_SESSION['selected'][$i] . '</option>';
        }
       
    ?>
    After user selected the date,page redirect to second page and display the selected date.Thanks for your generious help...

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    $_SESSION array is available from any page on the server.

    You simply must start/continue the session on every page across which the user travels. (using session_start(); at the top of each page).
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    I think he was talking about submitting data.

    You need to use $_POST/$_GET and forms to do that.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  4. #4
    Join Date
    Aug 2007
    Location
    Malaysia
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for reply.Problem resolvedThanks for reply,problem resolved
    Code:
    function GoToNextPage(value){
      if(value != ""){
           document.location = 'reservation2.php?selected_date=' + value;
      }
    
    <select name="rDate" onChange="GoToNextPage(this.value)">

    Code:
    <label>You selected <?= $_GET['selected_date']; ?>!</label>

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
  •