×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

session variable manage sample by lua server package

<html>
<!-- example session variable usage -->
<?lsp
print("<h2>session variables</h2>");
print("<pre>");
session = request:session() -- returns nil/false if there is no session
if session then
print("we have a session ", session)
session.counter = (session.counter or 0) + 1 --count session usage of this page

session:maxinactiveinterval(60);
print ("id", session:id());
print ("creationtime" ,os.date("%c",session:creationtime()))
print ("lastaccessedtime" ,os.date("%c",session:lastaccessedtime()))
print ("maxinactiveinterval" ,session:maxinactiveinterval())
print ("usecounter" ,session:usecounter())

-- if we have any attributes print them all
if session:attributes() then
table.foreach(session:attributes(), print)
end
end
print("</pre>")
?>
</html>
Report

Replies, comments and Discussions:

  • 工作学习 / 学科技术讨论 / 这里有自己写web app的吗?我现在在写基于jsp/servlet/xsl/mysql系统的全套java框架程序,用netbeans. 系统的可用户设定,个性化操作,框架在不同case下的普遍适用,快速customize,是这次总体设计,编程的优先考虑。
    • you can use lua server package, it's easy to be implemented.
      • It is a script language, user-level, you have no control of how to manage session variables, event handler, listener, construct DOM tree, align protlet variables, etc. What I am doing is a light weight Java framework.
        I will show an online example shortly:

        a. Instant language switch.
        b. Instant online text translation support.
        c. Webpage layout re-organization.
        d. CSS fine-tune to each UI component.
        e. Fast build UI block.
        f. Each backend / frontend component can be reusable, configurable.
        g. Only Tomcat / Java / Jdom are required.
        h. iText library implemented and building PDF dunamically.
        • didn't get your points yesterday. I have no experience of web app. lua server package is suitable for embedded light weight server, and provide the interactive configuration interface of device.
        • session variable manage sample by lua server package
          <html>
          <!-- example session variable usage -->
          <?lsp
          print("<h2>session variables</h2>");
          print("<pre>");
          session = request:session() -- returns nil/false if there is no session
          if session then
          print("we have a session ", session)
          session.counter = (session.counter or 0) + 1 --count session usage of this page

          session:maxinactiveinterval(60);
          print ("id", session:id());
          print ("creationtime" ,os.date("%c",session:creationtime()))
          print ("lastaccessedtime" ,os.date("%c",session:lastaccessedtime()))
          print ("maxinactiveinterval" ,session:maxinactiveinterval())
          print ("usecounter" ,session:usecounter())

          -- if we have any attributes print them all
          if session:attributes() then
          table.foreach(session:attributes(), print)
          end
          end
          print("</pre>")
          ?>
          </html>