Set php session via ajax

前端 未结 3 1862
心在旅途
心在旅途 2020-12-17 01:07

I\'m trying to build my AJAX login system but I\'m having some problems with PHP sessions.

This is the AJAX code I use in my index.php:

         


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-17 01:49

    You need to initiate the session first, like session_start().then only you can have the access to session variables. Have a look at this simple example , it might help you:

    aj.php

    
    
    
    

    sess.php

      
    

    As other guys pointed out, better you can also check for session_start() in the page where you reading the session variables.

提交回复
热议问题