-1

My Flowchart

I have a table with colname(INT) which i would like to pass its value to use with my $_SESSION variable

What i want to do: I want all my protected pages not to viewed more than a certain time which would be determined by the value of a colname(INT) use with $_SESSION.

SOLUTION: Just to determine/limit how long a user spends on all protected pages active or inactive.

2 Answers2

1

You can try this link

How to set session timeout code in PHP

Also, I don't see a point why you are storing password in session (Register username and password as session variables). You can validate the login credentials from DB and only then store some data about the user in session.

Community
  • 1
  • 1
Prasad K - Google
  • 2,584
  • 1
  • 16
  • 18
  • You seem not to understand the question above, its not just session time out, a table column contains values in INT(), let call it timer to be used with $_SESSION; am thinking like it could be $_SESSION[Username] ==$timer; just trying to crack my brain if i can i wouldn't ask... – WebPalaceLabs Sep 06 '14 at 05:35
  • There is no default way of achieving what you are asking for. You will need to check how much time has elapsed since the session started and compare with your db column value to see if it's expired. The link I have provided is a reference for you to take a look and and try – Prasad K - Google Sep 06 '14 at 05:40
  • i do i compare my db column value with when the session started? i have gone through the link you shared.. – WebPalaceLabs Sep 06 '14 at 05:44
0

OK as I understood your question you want to restrict a user to view a particular page only for few times.

You can do that by saving the views in database that is OK.

And you want to store the views in $_SESSION as the user login.

You can do that as follows:

if(login = success)
$_SESSION['viewCount'] = mysql_query("SELECT views FROM user WHERE userId=".$username.";");

I hope this will help

Cybersupernova
  • 1,833
  • 1
  • 20
  • 37