Jump to content

[SOLVED] Session Wont Hold.


Shilo

Recommended Posts

<?php
session_start();
$passpw = $_POST['password'];
$userac = $_POST['username'];
if ($action == 'login'){
$sql="SELECT * FROM user
WHERE username = \"$userac\" AND password = \"$passpw\"";
$result = @mysql_query($sql,$connection) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $query . "<br />\nError: (" . mysql_errno() . ") " . mysql_error());
$num=mysql_num_rows($result);
while ($row = mysql_fetch_array($result)) {
$active = $row['active'];
$confirm = $row['confirm'];
$valid_user = $row['valid_user'];
}
if($active == "no") {
$error = 'You have Been Banned From For Abuse On Our Forums!';
}
if($confirm == "no"){
$error = "Your Email Address Hasnt Been Yet Confirmed!";
}
elseif($active == "yes") {
$_SESSION['valid_user'] = $valid_user;
$error = 'Login Successful';
}
elseif($passpw == NULL) {
$error = 'You Did Not Enter A Password';
}
elseif($userac == NULL) {
$error = 'You Did Not Enter A Username';
}
elseif($valid_user == NULL) {
$error = 'You Entered Incorrect Login Information';
}
}
elseif ($action = 'logout'){
session_destroy();
}
?>

 

For some reason the session will only stay registered on that page. Once I leave I lose the session data and my account logs out. I have session_start(); on everypage. but it still doesnt want to stay registered. Any suggestions?

Link to comment
https://forums.phpfreaks.com/topic/142070-solved-session-wont-hold/
Share on other sites

I am such a retard!  ::)

 

This is the error:

<?php
elseif ($action = 'logout'){
session_destroy();
}
?>

 

Was supposed to be:

<?php
elseif ($action == 'logout'){
session_destroy();
}
?>

 

3 Hours!!! 3 hours and alot of stress. and 2 bottles of beer down the drain! For what? Just for 1 equals sign!!

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.