Jump to content

Unset session variable after a few seconds?


coupe-r

Recommended Posts

Hi All,

 

When a user saves the page, I want to have the page refresh to show the new record and then have a message saying "Success!" or something like that.

 

The only way I know how to do this is to set a session var after the record is created, but I would then need to unset it automatically so it doesn't keep showing.

 

Any suggestions?

What you said makes sense:

 

Form Processor:

// >> Check First
If(isset($_SESSION['var'])){ 
   unset($_SESSION['var']);
   echo("Success!"); }
else{
   // Do the editing
   $_SESSION['var'] = true;
   header(location: ...);
}

 

hope this helps

Sweet.  I thought there was something important I was missing.

 

Works great.  Thank you.

 

Here is what I am using when an action is taken:

$_SESSION['created'] = '<font size="3"><strong>Note Deleted!</strong></font>';

 

Here is the code at the top of the page:

if(isset($_SESSION['created']))
{
$created = $_SESSION['created'];
unset($_SESSION['created']);
}

 

The reason I make $created, is because the session var is being unset and would never show up.

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.