Page 1 of 1

User Logout Message

Posted: Fri Jun 24, 2011 1:13 pm
by kkohlmorgen
Hi there, I'm new to php development, and I need some assistance. I've created a login that uses the SESSION superglobal to authenticate the user. When the user logs in they are greeted by a message that includes their username. I do this through a function I created:

Code: Select all

function session_text($session_text_input) {
	$sql = "SELECT * FROM users WHERE uid = " . $_SESSION["uid"];
	$result = mysql_query($sql);
	$array = mysql_fetch_array($result);
	print_r ($array["$session_text_input"]);
}
The function works perfectly when the user logs in. However this is not the case when the user logs out. I would like to be able to have another message telling the user that they have logged out successfully with their username included in the message. This is difficult because I have already destroyed the session, therefor my function that calls the session in question no longer exists.

If anyone has any ideas or a work around, I would be very grateful. Thank you.

Re: User Logout Message

Posted: Fri Jun 24, 2011 4:07 pm
by pickle
3 options, in order of best -> worst

1) Don't output the username. Once the user has logged out, there should be no indication they were ever there.
2) Write a new function to pull the info out of $_SESSION before it is destroyed, but return the string to output rather than echo-ing it.
1) Modify your function to accept another parameter - the username