Q:

session variable use in another php page

I want to use session variable in another page. I used data which is got from database to store in variable. When I try to use it another page error god undefined  index. Code is below. help me to solve this
    <?php
    session_start();
    require('dbconnection.php');
    $output='';
    $sql="select * from vacancy";
    $res=mysqli_query($conn,$sql);
    if(mysqli_num_rows($res)>0){

    while($row=mysqli_fetch_assoc($res)){
    $imageno=$_SESSION[$row['vacancyid']];
    ?>

other.php page
    <?php
    session_start();
    ?>
    <div>
    <?php

    $src='images/vacancy/'.$_SESSION["imageno"].'.jpg';
    echo "<img src='".$src."'>";
    ?>
    </div>

A:

This isn't setting a session variable, it's trying to read one:
$imageno=$_SESSION[$row['vacancyid']];

It sounds like you meant to do this instead:
$_SESSION["imageno"] = $row['vacancyid'];

That is, to read the database row and set the value to the session.

