User Tools

Site Tools


accesstoken_class

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
accesstoken_class [2019/11/04 20:21] sahlaccesstoken_class [2021/02/11 13:47] (current) – [Accesstoken class] Explained anonymous token sahl
Line 20: Line 20:
 </code> </code>
  
-It is typically associated with a user, which can be done easily like:+This is boiled into a number of methods. 
 + 
 +<code php> 
 +$token = Accesstoken::acquireAnonymous(60*60); 
 +</code> 
 + 
 +The code above acquires an access token which isn'associated with any user, and lasts for one hour. 
 + 
 +To associate an access token with a user, this is done like:
  
 <code php> <code php>
Line 28: Line 36:
 </code> </code>
  
-To check if user is allowed one can simply do one of the following:+To check for valid access token, do one of the following:
  
 <code php> <code php>
Line 36: Line 44:
  
 // The options below will cause a successful validation to make the session valid for ten more minutes. // The options below will cause a successful validation to make the session valid for ten more minutes.
-Accesstoken::validateSession('/url-to-not-logged-in', true, 3600);+Accesstoken::validateSession('/url-to-not-logged-in', true, 600);
 </code> </code>
 +
 +If you make a check like above and redirect the user to a login-page, you can afterwards call the ''resumeLocation()''-function to return the user to the place where the check failed.
  
 ===== Logout ===== ===== Logout =====
accesstoken_class.1572898881.txt.gz · Last modified: 2019/11/04 20:21 by sahl

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki