Jump to content

$_SESSION Variables not resetting


The14thGOD

Recommended Posts

Basically I am using PHP to validate a form and if the user has to go back it makes a bunch of $_SESSION variables and stores what the user put in.

Now it stores it and repopulates the form correctly the 1st time. However, if I go in and change things and still "make a mistake" it keeps the old data. It doesn't overwrite.

IE If I had a name field and changed it from John to Joe it would stay as John when it comes back saying I missed something yet again.

Here's the code that I'm using to set and overwrite the variables (they're more variables but its the same thing so I took them out)

<?php
import_request_variables('pg');
if($format == 1) {
//stuff
}else {
	session_start();
	$_SESSION['category'] = $category;
	$_SESSION['format'] = $format;
	$_SESSION['homepage'] = $homepage;
	header("Location: index.php?error=format");
	exit(0);
}
?>

Basically if I dont enter anything into format it shoots back telling me I have to select something for format. So if I miss something again and I ended up changing a bunch of things, it doesnt change. It keeps the old values I put in.

This may not be the most efficient way but it's the quickest way I know (on a budget). It works on my server for my website but doesn't work on this server Im testing on.

Is there a global php setting that I need to enable/set?

Thanks for any and all help,

 

Justin

Link to comment
https://forums.phpfreaks.com/topic/140750-_session-variables-not-resetting/
Share on other sites

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.