sessions

Faruk S. Can farukscan at gmail.com
Sat Mar 15 17:40:14 UTC 2014


my problem persists. once it has gone but i could not figure out how.
but now the problem is back.
any help?


On Wed, Mar 12, 2014 at 7:19 PM, Faruk S. Can <farukscan at gmail.com> wrote:

> hi
> i cannot sustain a session.
> i login to my app. it shows my login name as i programmed.
> when i refresh the page it stays there.
> but when i refresh for the second time my session name and
> other things goes away and instead i see what is there for the
> not loginned case.
>
> I think i miss something in hunchentoot session hadling.
>
> ;all html generated by a macro:
>
> (defmacro ff (tag)
>   `(defun ,tag (&rest c)
>      (with-output-to-string (*standard-output*)
>        (format t "<~a ~{~a='~a' ~}> ~{~a ~}</~a>" ',tag (car c) (cdr c)
> ',tag))))
>
> ;;defining all tag functions:
> (progn
>   (ff html)
>   (ff title)
>   (ff head)
>   (ff meta)
>   (ff link)
>   (ff style)
>   (ff script)
>   (ff body)
>   (ff span)
>   (ff div)
>   (ff section)
>   (ff p)
>   (ff form)
>   (ff input)
>   (ff button)
>   (ff textarea)
>   (ff a)
>   (ff h1)
>   (ff h2)
>   (ff h3)
>   (ff h4)
>   (ff h5)
>   (ff h6)
>   (ff ol)
>   (ff ul)
>   (ff li))
>
> ;authentication utilities used by the home page function at the bottom:
>
> (defun signed-in-p ()
>   (if (and (boundp '*session*) (session-value '*signed-in *session*))
>       t
>       nil))
>
> (defun signed-up-p (x y)
>   (if (with-connection *conn1spec*
>          (query  (:select 'username 'password :from 'users.users
>                           :where (:and (:= 'username x)
>                                        (:= 'password y)))))
>     t
>     nil))
>
> (defun sign-in ()
>   (let ((username (parameter "username"))
> (password (parameter "password")))
>     (if (signed-up-p username password)
>       (progn
>         (start-session)
>         (setf (session-value '*username) username)
>         (setf (session-value '*signed-in) t)
>         (morph-status-plate (session-value '*username)))
>       (with-output-to-string (s)
>         (princ (morph-sign-in-form) s)
>         (princ "No record found!" s)
>         (princ (a (list :href "/form-sign-up") "Sign up") s)
>          ))))
> ;the data base querying functions are working correctly
> ;views generated:
>
> (defun morph-write-button ()
>   (div (list :style "border:1px solid; float:left;")
>      (a (list :href "/writingp") "write")))
>
> (defun morph-status-plate (username)
>    (div (list :id "status-plate" :style "border:1px solid; float:left;")
>      (span () "123 users online")
>      (span () username)
>      (button (list :onclick "ajaxlogout()") "logout")))
>
> (defun morph-sign-in-form ()
>   (div (list :id "sign-in-form" :style "border:1px solid; float:left;")
>    (form (list :method "" :action "")
>     (input (list :id "username" :type "input" :name "username"))
>     (input (list :id "password" :type "input" :name "password"))
>     (input (list :onClick "ajaxsignin()" :type "button" :value "login")))))
>
> ;at last
> ;the page i generate as home page:
> (div (list :id "sign-in-form-or-status-plate"
>                       :style "height: 45px; border: 1px solid;
> float:left;")
>                 (if (signed-in-p);;;;;;
>                   (with-output-to-string (s)
>                     (start-session)
>                     (princ (morph-status-plate (session-value '*username))
> s)
>                     (princ (morph-write-button) s))
>                   (with-output-to-string (s)
>                     (princ (morph-sign-in-form) s)
>                     (princ (a (list :href "form-sign-up") "Sign up") s))))
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/tbnl-devel/attachments/20140315/51db6278/attachment.html>


More information about the Tbnl-devel mailing list