Jump to content

[SOLVED] Can't get $_SESSION working


ana9

Recommended Posts

I have the following on a page: (I have session_start(); on all pages)
<?php
session_start();   
if (isset($_SESSION['auth'])=="yes")
{
  echo "<p>&nbsp;</p>
<p>&nbsp;</p>
<p align='center'><font face='verdana'>You are registered.</font></p>
";
}
etc..... ?>
so that when a user registers on another page if they hit the back button they cannot register a second time.

The person is redirected to a second page where their info is inserted into the mssql database then I call:
  $_SESSION['auth']="yes";   
to set the variable

When I run this setup on my local machine it works perfectly, however when I put it up on the server it does not work.  I am running sqlserver2005, windows server 2003, IIS6, php5.
Link to comment
https://forums.phpfreaks.com/topic/30815-solved-cant-get-_session-working/
Share on other sites

but isset does exactly that - it tells you if a var is set (ie, holds a value). [url=http://www.php.net/isset]isset[/url] returns either true or false. so what your check actually equates to is:
if TRUE/FALSE == 'yes'
which will always fail.

using both a check of being set as well as a check of its value should work:

[code]
<?php
if (isset($_SESSION['auth']) && $_SESSION['auth'] == "yes")
?>
[/code]

hope that helps
Cheers
Mark

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.