Total members 10262 | Gratitudes |It is currently Thu May 24, 2012 5:27 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 6 posts ] 
Author Question
 Question subject: login using sessionid or time
PostPosted: Tue Sep 20, 2011 7:55 am 
Offline
Newbie
User avatar

Joined: Tue Aug 09, 2011 12:50 pm
Posts: 7
Has thanked: 0 time
Have thanks: 0 time

hi all,
i have written a code in php using sessions.below is the code......

Code:
<?php
if(!isset($_SESSION))
{
session_start();
}
$now = time();
$limit = $now;
if(isset($_SESSION['last_activity']) && ($_SESSION['last_activity'] < $limit))
{
$_SESSION = array();
header('Location:logout.php');
exit;
}
else
{
//the current time
$_SESSION['last_activity'] = $now;
}
?>
.
tell me how to modify in the above code that if the user is entering for first
time then using time() or sessionid it should be stored
or else if he is entering for first time then using current time() or sessionid
it must be stored.....


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: login using sessionid or time
PostPosted: Thu Sep 22, 2011 11:14 am 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time
you want to save first time login date ! , you have to save such information in database or text file which i don't recommend.

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: login using sessionid or time
PostPosted: Thu Sep 22, 2011 11:17 am 
Offline
Newbie
User avatar

Joined: Tue Aug 09, 2011 12:50 pm
Posts: 7
Has thanked: 0 time
Have thanks: 0 time
i need to store in my database


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: login using sessionid or time
PostPosted: Thu Sep 22, 2011 11:59 am 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time
Code:

<?php
  $hostname
="localhost";
  
$username="username";
  
$password="password";
 
  
$dbconnectionmysql_connect ($hostname$username$password);
 
  if (!
$dbconnection) {
     die (
" cannot connect to database");
  }
 
  
$result=mysql_select_db ("databasename");
 
  if (! 
$result) {
     die (
"database could not be selected");
  }
     
  echo 
"Database ready.";
?>


Code:

  $query_res 
mysql_query"SELECT * from tableName" );
 


you may create a data column in users table , if its first time , store the time , any new visits check this column value , it null so its new visit , else it is not and do nothing.

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: login using sessionid or time
PostPosted: Thu Sep 22, 2011 12:37 pm 
Offline
Newbie
User avatar

Joined: Tue Aug 09, 2011 12:50 pm
Posts: 7
Has thanked: 0 time
Have thanks: 0 time
how it will store the time in the database


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: login using sessionid or time
PostPosted: Fri Sep 23, 2011 1:32 am 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time
It is easy like other PHP variables :
Code:

         $date 
= date("Y-m-d H:i:s"); 
         $query 
=" INSERT INTO `user` VALUES (0,null,'$country_code','$username','$firstname','$lastname','$password','
$address1',
'$address2','$telephone','$mobile','$email','$city',0,'$date','$date','$date_birthday','$gender',0,'$activationkey',0)"
;
         $result =mysql_query($query );
         echo mysql_error();
 

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 6 posts ] 
Quick reply


  

 Similar topics
 login using jsp
 Plz Help,I want BOTH THREAD to work at a time in SAME WINDOW
 php login form (sign-in form)
 Selecting a Domain Name at the Time of Registration
 Time countdown
 Having a hard time with this class need help deseperately.
 calculate the load time for a page
 Send login information
 Mile200: Removing Username, Password & Login from Header
 How to Show a message before the login ?

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team