Jump to content

[SOLVED] displaying array stored in a session from external page


emtec

Recommended Posts

i'm trying to transfer an array from one page to an other one, in a session

 

array /session:

<?php
$_SESSION['info'] = array();

 

array echo:

<?php
//check if info box  needs to be showen
if (!empty($_SESSION['info'])){
echo "<div class='info_message'>";
$nr = count($_SESSION['info']);
for ($row = 0; $row < $nr; $row++)
{   
   echo"<p><img src='images/icons/".$_SESSION['info'][$row]['icon']."' width='16' height='16' /> ".$_SESSION['info'][$row]['text']."</p>";
}
//close info box
echo "</div><!-- end info_message -->";
unset($_SESSION['info']); }

 

storing array in session on an other page:

<?php array_push($_SESSION['info'], array (icon => "add.png",text => ADMINADDINFO ));

 

i just get an empty session, if i copy the array push on the same page, it will work.

can any1 tell me what i'm doing wrong?

 

Link to comment
Share on other sites

i will post some more info, maby there is something wrong with somthing else

 

index.php

<?php
session_start();
$_SESSION['info'] = array();

//some other code

include('inc/infoboxes.php');

//some other code

 

inc/infoboxes.php

<?php
//check if info box  needs to be showen
if (!empty($_SESSION['info'])){
echo "<div class='info_message'>";
$nr = count($_SESSION['info']);
for ($row = 0; $row < $nr; $row++)
{   
   echo"<p><img src='images/icons/".$_SESSION['info'][$row]['icon']."' width='16' height='16' /> ".$_SESSION['info'][$row]['text']."</p>";
}
//close info box
echo "</div><!-- end info_message -->";
unset($_SESSION['info']); }
?>

 

external page

<?php
session_start();

// some other code

array_push($_SESSION['info'], array (icon => "add.png",text => ADMINADDINFO ));

Link to comment
Share on other sites

Okay, so let me get this straight: your coding order is this? (look at the comments I added):

 

index.php

<?php
session_start();
$_SESSION['info'] = array();

//some other code
// CALL EXTERNAL PAGE HERE

include('inc/infoboxes.php');

//some other code

 

external page

<?php
session_start();

// some other code

array_push($_SESSION['info'], array (icon => "add.png",text => ADMINADDINFO ));

// REDIRECT TO INDEX.PHP

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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