Jump to content

$_SESSION cant set


dreamwest

Recommended Posts

I cant seem to set this session for some reason:

 

<?php

session_start();


$comfirm = $_POST['confirm'];

if($confirm != ""){

$_SESSION['confirm'] = 1;
} 

if($_SESSION['confirm']){

$session = "ok";

echo "im set!!";
}
?>

<form action="" method="POST">
<input type="hidden" name="confirm" value="yes" >
<input style="margin-right: 5px; " type="submit"  value="Confirm User">
</form>

Link to comment
https://forums.phpfreaks.com/topic/174964-_session-cant-set/
Share on other sites

 

Try the following:


<?php
session_start();

if($_POST)
{
	$comfirm = $_POST['confirm'];

	if($comfirm)
	{
		$_SESSION['confirm'] = 1;
	} 

	if($_SESSION['confirm'])
	{
		$session = "ok";
		echo "im set!!";
	}
}
?>

<form action="" method="POST">
<input type="hidden" name="confirm" value="yes" >
<input style="margin-right: 5px; " type="submit"  value="Confirm User">
</form>

 

Link to comment
https://forums.phpfreaks.com/topic/174964-_session-cant-set/#findComment-922123
Share on other sites

For some reason the $confirm variable was interfering, dont know why but it now works:

 

<?php

session_start();

$yes = $_POST['confirm'];

if($yes != ""){

$_SESSION['confirm'] = 1;
} 

if($_SESSION['confirm']){

$session = "ok";

echo "im set!!";
}
?>

<form action="" method="POST">
<input type="hidden" name="confirm" value="yes" >
<input style="margin-right: 5px; " type="submit"  value="Confirm User">
</form>

Link to comment
https://forums.phpfreaks.com/topic/174964-_session-cant-set/#findComment-922190
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.