Jump to content

Session variables disapearing


avingard

Recommended Posts

I have the following problem

 

on one page I have this code:

 

session_start();

$_SESSION['var'];

header("location:page2.php");

 

I've commented out the header line and tested to make sure var registers, and it does on that page, but as soon as I redirect the page, I have this code first thing on page2

 

if(isset("$_SESSION['var']"))

{

//codecode

}

 

the problem is, isset ALWAYS returns false.  What's happening to var?

Link to comment
https://forums.phpfreaks.com/topic/109678-session-variables-disapearing/
Share on other sites

Dear

 

Firstly you need to start the session as you do

secondly you need to give it a value to see

on different pages

 

  like one person shown above $_SESSION[' anyvarialbe'] = 'value or variable you like to give here ';

 

  and

 

  isset() and empty() both works same but better is to use the empty()

  because it is much better then isset() function.

 

  and always use like this in the following funtions

  empty( $_SESSION[' '])

 

  header("Location: redirct_pagename.php"); is the correct syntax to use.

 

  hope you get the point

 

 

 

 

 

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.