Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6939737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:39:37+00:00 2026-05-27T12:39:37+00:00

I am trying to implement a thing like OAuth in PHP and what I

  • 0

I am trying to implement a thing like OAuth in PHP and what I want to do is give tokens to users so they can use their private resources. Every user first must login with their email and password and get a unique token which would be valid forever unless it’s idle for “n” minutes. So if there are zero requests for “n” minutes, the token should be destroyed. The token would be used to access private resources by users.

One thing I can think of doing this is as…

I would maintain a db table of named user_tokens and as they login with their username and password the entry with unique token would be created there. The last accessed timestamp would be set and user would given the unique token as response. The token now can be used to access private resources of user and would be required to pass with all request requiring token. Every private request would check if the last timestamp and current timestamp has “n” minutes of difference, if yes, destroy token. Otherwise send response with requested resources and set last timestamp to current timestamp.

Does that make sense? Or there can be another efficient way of doing this?

I would like to add that the token must be like what twitter or facebook returns out of their API.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:39:38+00:00Added an answer on May 27, 2026 at 12:39 pm

    If you’re looking to implement OAuth using a library you should check out the HTTP_OAuth pear package by Jeff Hodson of Digg[1], and there are a bunch of good posts on this site about database design to use with Oauth[2].

    I think I’m confused about your question, though. Are you looking to make an API for your web application, or just provide a way to protect a user’s resources? If you want to make an API, you should definitely use OAuth and also use a well known library. Doing so will ensure that:

    1. Other developers will know how to use your API because it follows the OAuth RFC[3]
    2. Your web application is much more likely to be secure
    3. You become aware of best practices and learn some new stuff

    If you aren’t looking to make an API, and just want to protect user resources, I think you would be safe using sessions[4], and, if the user is not logged in they can’t access the protected resources.

    [1] HTTP_OAuth Package : http://pear.php.net/pepr/pepr-proposal-show.php?id=607
    [2] Oauth Database Design : what is the recommended database structure for OAuth Provider
    [3] Oauth RFC : http://oauth.net/
    [4] PHP Sessions : http://us2.php.net/manual/en/features.sessions.php

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement language switching in .htaccess, and the only thing left now
Trying to implement a rating system of users and postings. What is the best
I'm trying to implement something like a photo carousel in jQuery. This carousel could
I'm currently trying to implement a StopWatch class. The interface is something like: interface
I'm trying to implement a UISearchBar within a UITableView , which behaves like the
I am trying to implement routing in cakephp. I want the urls to mapped
I'm trying to implement a Paginator like this: public class MyPaginator : DocumentPaginator{ //
I'm trying to implement this project: http://img7.imagebanana.com/img/cnb46ti2/relationships.png I want to let view the skills
I would like to play with scala.ref.WeakReference . However, before trying to implement the
I am trying to implement content browsing like it is done on Facebook when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.