session error

Started on the old forum in August 2010 · view the original in the archive · old links redirect here

2 replies · 433 views · started 16 years ago · 1 min read

3 participants
jaidon20k Developer · 64 posts #1

Pls Friends what happy to this below code, it keep on telling me session expire lol

<?php define('WAP',true); require('db.php'); session_start(); $ses = $_SESSION['ses']; $sessions = mysql_fetch_array(mysql_query("SELECT * FROM sessions WHERE ses = '$ses'")); $time = time(); echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> <html xmlns=\"http://www.w3.org/1999/xhtml\"> <head> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/> <meta http-equiv=\"Cache-Control\" content=\"no-cache\"/> <meta http-equiv=\"Cache-Control\" content=\"must-revalidate\"/> <meta http-equiv=\"Cache-Control\" content=\"max-age=30\"/> <title>Home</title> </head> <body>"; if (mysql_num_rows(mysql_query("SELECT * FROM sessions WHERE ses = '$ses'")) == 1) { if ((time()-$sessions['time']) < 300) mysql_query("UPDATE sessions SET time = $time WHERE uid = $sessions[uid]"); } else { echo "Your session has expired <form action=\"index.php\" method=\"get\"> <input type=\"submit\" value=\"Index\"/> </form> </body> </html>"; exit(); } mysql_query("UPDATE members SET lastseen = $time WHERE id = $sessions[uid]")or die(mysql_errno()." - ".mysql_error()); echo "welcome please feel free to look around. <form action=\"logout.php\" method=\"get\"> <input type=\"submit\" value=\"Logout\"/> </form> </body> </html>"; ///////////////////////////database CREATE TABLE `sessions` ( `uid` int(100) unsigned NOT NULL auto_increment, `user` varchar(50) default NULL, `ses` varchar(50) default NULL, PRIMARY KEY (`uid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7
nclemale36 Lead · 537 posts #2

there is no time field in your database table

if ((time()-$sessions['time']) < 300) mysql_query("UPDATE sessions SET time = $time WHERE uid = $sessions[uid]");

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close