Jump to content

Sessions


shg2001

Recommended Posts

You have program A it calls program B,the data stored in program A should be passed to program B using session, but when program A calls program B, program B has no data.

 

Program A - Starts

 

<?php

 

session_start();

 

<code>

....

...

<code>

header("location: http://Program B.php");

 

Program B - Starts

 

<?php

 

session_start();

 

<code>

....

...

<code>

 

 

any though as to what i might be going wrong ...  as to why the data does not pass from one program to another

 

thanks

SHG :'(

Link to comment
https://forums.phpfreaks.com/topic/91889-sessions/
Share on other sites

regarding retreiving the session.  I don't honestly know if i am doing that correctly at all.  I looked at all the documentation i could find and it all states use session_start(); at the top of each program.  But in the docs it never gives you the code for the receiving program only the sending program......  So how do u retreive the session from the sending program???

 

 

thanks

SG

Link to comment
https://forums.phpfreaks.com/topic/91889-sessions/#findComment-470622
Share on other sites

$_SESSION is an associative array in which you can assign key/value pairs. The values can be any PHP variable type.

 

<?php
  session_start();
  $_SESSION['test'] = array();
  $_SESSION['test'][] = "I was set in Page A";
  $_SESSION['test'][] = "I am another value in the array";
  header('Location: pageb.php');
  exit;
?>

 

<?php
  session_start();
  print_r($_SESSION['test']);
?>

Link to comment
https://forums.phpfreaks.com/topic/91889-sessions/#findComment-470650
Share on other sites

<?php

  session_start();

  $_SESSION['test'] = array();

  $_SESSION['test'][] = "I was set in Page A";

  $_SESSION['test'][] = "I am another value in the array";

  header('Location: pageb.php');

  exit;

 

<?php

  session_start();

  print_r($_SESSION['test']);

?>

 

How would you print the second element of the array "I am another value in the array";

echo "this is the second Element".$_SESSION['test'][1];

 

Link to comment
https://forums.phpfreaks.com/topic/91889-sessions/#findComment-470652
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.