Jump to content

Recommended Posts

Hello,

I have developed a page selecting and displaying data from a DataBase(mysql), as following

$result = mysqli_query($conn, $sql);

$fetch = mysqli_fetch_row($result);  

$row_code = $fetch[0];

session_start();

$_SESSION['pel_seqno'] = $row_code; 

The above page has tabs. In the second tab i access the $_SESSION['pel_seqno'] as following

<?php

    $seqno_pel='';

    $seqno_pel = $_SESSION['pel_seqno']; 

I use $seqno_pel variable to retrieve some other data from another table in the DataBase. So far so good, Inside the tab i have a button redirecting in another page and i want to use the value of $_SESSION['pel_seqno']; and i can not.

The code which i am trying to access again the $_SESSION['pel_seqno'];  is the following

<?php    

    $seqno_pel = $_SESSION['pel_seqno'];  

When the button is pressed i get the following error message

Warning: Undefined variable $_SESSION in D:\PROGRAMS\XAMPP\htdocs\CARDIO\Pel_Rv.php on line 5
Warning: Trying to access array offset on value of type null in D:\PROGRAMS\XAMPP\htdocs\CARDIO\Pel_Rv.php on line 5

Is it possible someone to help me with this.

Thank you in advance

 

Link to comment
https://forums.phpfreaks.com/topic/313526-session-problem/
Share on other sites

Obviously you didn't start the session in this script execution.

 

I always place the session start line at the top of my scripts.  It certainly doesn't hurt.  Don't do it somewhere else that you think it will happen when it needs to.  At the top where you can be sure it happens.

Link to comment
https://forums.phpfreaks.com/topic/313526-session-problem/#findComment-1588987
Share on other sites

Thanks you for your answer

When i place the session_start() at the begining of the script, then the following error occurred ( Notice: session_start(): Ignoring session_start() because a session is already active in Pel_Rv.php on line 5 ), but the code runs correctly. My code is

<? php

 $seqno_pel='';   

    session_start();

    error_reporting(E_ALL);

    ini_set('display_errors', '1');

Link to comment
https://forums.phpfreaks.com/topic/313526-session-problem/#findComment-1588990
Share on other sites

As Barand is saying you should change back to all errors.  Ignoring warnings is not a good idea.

Apparently you are already issuing the session start in an earlier part of your executing script.  One should place the session start in that place always and not in any 'included' modules later on.  That is what it looks like you are doing.  The script that your url is calling is the starting point - session start s/b there as close to the start as allowed.

Link to comment
https://forums.phpfreaks.com/topic/313526-session-problem/#findComment-1588995
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.