ajax session php

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Beshoo

    #1

    ajax session php

    hey gaiz plz I want to cerate log in system in ajax i do it but i have
    one problem

    AFTER I start thes session then press refresh key the session gone !!!
    in other words , after the user type hid username and password I send
    this information by XMLrequest to php file which verify the user name
    and the password if trure open the sesstion and get it name 'user' its
    become like this

    $_SESSION['user']=$user;

    actually after i open the sesstion_start( );

    BUT THE PROBLEM IS WHN I PRESS F5 "refresh the page the sesssion is
    gone


    ANY WAY OUT PLZ :)

    alot of htanx in advance

  • Rik

    #2
    Re: ajax session php

    Beshoo <basheermoro@gm ail.comwrote:
    hey gaiz plz I want to cerate log in system in ajax i do it but i have
    one problem
    >
    AFTER I start thes session then press refresh key the session gone !!!
    in other words , after the user type hid username and password I send
    this information by XMLrequest to php file which verify the user name
    and the password if trure open the sesstion and get it name 'user' its
    become like this
    >
    $_SESSION['user']=$user;
    >
    actually after i open the sesstion_start( );
    >
    BUT THE PROBLEM IS WHN I PRESS F5 "refresh the page the sesssion is
    gone
    >
    >
    ANY WAY OUT PLZ :)
    >
    alot of htanx in advance

    So, you were in a hurry in typing, weren't you?
    When using this kind of thing to login, first consider wether or not this
    breaks your total page becomes useless without javascript. Create a nice
    fallback.

    Now, the way you use it, only cookies can be used to hold the session_id,
    PHP is not there for you to rewrite GET or POST variables (or you have to
    do it with javscript... messy). I think it might be a security issue,
    where the cookie received by a javascript call is not set/denied by the
    browser. Try to:
    - check with javascript wether or not the cookie is set after your request.
    - print the session_id to screen
    - check the headers that are sent on refresh

    --
    Rik Wasmus
    Posted on Usenet, not any forum you might see this in.
    Ask Smart Questions: http://tinyurl.com/anel

    Comment

    • dschreck@gmail.com

      #3
      Re: ajax session php

      On Mar 9, 8:55 am, "Beshoo" <basheerm...@gm ail.comwrote:
      hey gaiz plz I want to cerate log in system in ajax i do it but i have
      one problem
      >
      AFTER I start thes session then press refresh key the session gone !!!
      in other words , after the user type hid username and password I send
      this information by XMLrequest to php file which verify the user name
      and the password if trure open the sesstion and get it name 'user' its
      become like this
      >
      $_SESSION['user']=$user;
      >
      actually after i open the sesstion_start( );
      >
      BUT THE PROBLEM IS WHN I PRESS F5 "refresh the page the sesssion is
      gone
      >
      ANY WAY OUT PLZ :)
      >
      alot of htanx in advance
      Make sure session_start() is at the top of every file.
      Try setting the php ini setting to use cookies for sessions, and make
      the session lifetime greater.
      should work.

      Comment

      • Satya

        #4
        Re: ajax session php

        On Mar 9, 1:19 pm, dschr...@gmail. com wrote:
        On Mar 9, 8:55 am, "Beshoo" <basheerm...@gm ail.comwrote:
        >
        >
        >
        hey gaiz plz I want to cerate log in system in ajax i do it but i have
        one problem
        >
        AFTER I start thes session then press refresh key the session gone !!!
        in other words , after the user type hid username and password I send
        this information by XMLrequest to php file which verify the user name
        and the password if trure open the sesstion and get it name 'user' its
        become like this
        >
        $_SESSION['user']=$user;
        >
        actually after i open the sesstion_start( );
        >
        BUT THE PROBLEM IS WHN I PRESS F5 "refresh the page the sesssion is
        gone
        >
        ANY WAY OUT PLZ :)
        >
        alot of htanx in advance
        >
        Make sure session_start() is at the top of every file.
        Try setting the php ini setting to use cookies for sessions, and make
        the session lifetime greater.
        should work.
        I assume it is not session but the page refresh in Ajax.
        When you refresh a page in ajax all data is be lost.
        For this you should use login without Ajax. After login you can use
        Ajax for another things.
        And remember at the first page also from where you are using ajax, use
        session_start() ;


        Comment

        Working...