由于session导致的用户状态频繁丢失

福尔摩斯对我笑 2018-09-19 55630 次 8965条

今天收到用户的反馈,说登录后,经常会丢失登录的状态,导致下单时需要频繁登录。

收到反馈后,开始了测试,进行了数十次,并没有发现客户所反应的问题。后来我无意间切换了下网络,然后就发现问题重现了。经排查,发现该问题是由于Session导致的,尤其对于动态IP地址的客户,极为严重。

Ecshop默认的session机制

ecshop中的session和默认的session机制是不一样的。ecshop的session是自己定义的。
ecshop的session原理是基于cookie和ip综合处理生成的随即session字符串的。

ecshop的session就是当你建立一次会话之后,就会通过cookie和ip综合运算形成随即的session_id,存储在session表中。

Session建立的流程

当我们请求ecshop页面,那么就会建立session。

通过includes/init.php初始化

$sess = new cls_session($db, $ecs->table('sessions'), $ecs->table('sessions_data'));   //$sess就是新的session对象。

define('SESS_ID', $sess->get_session_id())

在session的类中, $GLOBALS['_SESSION'] = array();就是初始化session全局变量,$this->_ip = real_ip();

这就导致了session和ip有关。所以很多时候,在不同的浏览器下面,会造成session丢失。这个时候我们就该考虑到因为IP引起ecshop session的异常。

解决问题

所以我们需要修改Ecshop的源码,将session生成的机制重新做处理。

 

标签:

非特殊说明,本博所有文章均为博主原创。

头像也是LOGO
未来博客 博主大人
到了这个年纪,不应该再彷徨!

发表评论



 


已有 8965 条评论 1


  1. curry 4

    My husband and i have been very lucky Chris could finish up his researching from the ideas he was given while using the web pages. It’s not at all simplistic to just always be giving for free methods which usually a number of people could have been selling. We take into account we’ve got the website owner to thank for that. The most important illustrations you’ve made, the straightforward blog navigation, the relationships you will aid to foster – it’s got all unbelievable, and it is helping our son and the family do think this subject matter is enjoyable, which is unbelievably serious. Thanks for everything!

    回复 2019年10月25日
  2. jordan shoes

    Thank you so much for providing individuals with remarkably special possiblity to read critical reviews from this blog. It is usually very beneficial and as well , stuffed with a good time for me personally and my office friends to search your website nearly 3 times in a week to find out the new secrets you will have. Not to mention, we are at all times pleased with all the great ideas served by you. Certain 1 areas in this post are basically the very best we’ve ever had.

    回复 2019年10月25日
  3. longchamp handbags

    A lot of thanks for every one of your hard work on this web site. My mom loves working on investigation and it is simple to grasp why. All of us notice all concerning the lively ways you make very helpful information via this web blog and even boost contribution from other ones on the subject plus our simple princess is truly understanding a whole lot. Enjoy the remaining portion of the new year. Your conducting a dazzling job.

    回复 2019年10月24日
  4. timberlands

    I definitely wanted to type a simple word in order to thank you for all of the precious facts you are sharing here. My incredibly long internet lookup has now been rewarded with incredibly good ideas to talk about with my close friends. I would tell you that many of us website visitors actually are really fortunate to be in a fine community with so many perfect individuals with helpful concepts. I feel extremely fortunate to have discovered your web site and look forward to some more entertaining moments reading here. Thank you once more for a lot of things.

    回复 2019年10月24日
  5. balenciaga sneakers

    I simply had to appreciate you once more. I am not sure the things that I would have handled in the absence of the actual tips contributed by you relating to that concern. It had been an absolute daunting condition for me personally, nevertheless discovering a new specialized technique you processed the issue forced me to cry over fulfillment. I will be thankful for this help and thus expect you are aware of an amazing job your are accomplishing teaching most people via your web blog. I am certain you haven’t come across all of us.

    回复 2019年10月24日
  6. nike shox for women

    I want to express my thanks to you for rescuing me from this particular scenario. Because of checking through the online world and coming across ways that were not powerful, I assumed my entire life was done. Being alive without the presence of strategies to the issues you’ve fixed all through this guideline is a crucial case, as well as ones that might have in a negative way damaged my career if I hadn’t noticed the website. Your primary understanding and kindness in controlling all areas was useful. I am not sure what I would’ve done if I had not encountered such a step like this. I’m able to at this point relish my future. Thanks a lot very much for this impressive and results-oriented help. I will not hesitate to suggest the sites to anyone who ought to have direction on this subject.

    回复 2019年10月23日
  7. yeezy boost

    I precisely desired to appreciate you again. I am not sure the things that I would’ve accomplished in the absence of the actual creative ideas contributed by you over this problem. Previously it was a very distressing crisis for me personally, but finding out the very skilled tactic you treated it took me to cry over delight. I’m happy for the service and in addition believe you are aware of a powerful job you happen to be putting in educating the others using a blog. I’m certain you’ve never got to know any of us.

    回复 2019年10月23日
  8. curry 6 shoes

    A lot of thanks for all your efforts on this web page. Gloria really likes managing internet research and it’s obvious why. We know all regarding the compelling mode you deliver invaluable tips via the website and even invigorate contribution from others on that matter plus our own princess is certainly being taught a great deal. Enjoy the remaining portion of the year. You are carrying out a great job.

    回复 2019年10月20日
  9. nike vapormax

    I precisely wished to appreciate you once more. I do not know the things I could possibly have tried in the absence of the creative ideas discussed by you over my industry. This was a hard situation in my view, but viewing this skilled fashion you handled that made me to jump for joy. Extremely grateful for this service as well as wish you are aware of a powerful job you were putting in instructing others all through your web site. More than likely you haven’t met any of us.

    回复 2019年10月19日
  10. yeezy boost 350

    I enjoy you because of all of your labor on this web page. Gloria takes pleasure in working on internet research and it is easy to see why. My partner and i notice all regarding the powerful mode you render insightful information on the web blog and as well as recommend participation from others about this matter while our own simple princess is actually being taught a whole lot. Take advantage of the remaining portion of the year. Your performing a really great job.

    回复 2019年10月15日
  11. off white x jordan 1

    I actually wanted to jot down a simple word to thank you for the splendid tips and tricks you are posting on this website. My extensive internet search has at the end been rewarded with good quality tips to share with my partners. I ‘d suppose that we readers actually are truly endowed to be in a magnificent community with so many marvellous professionals with helpful hints. I feel rather fortunate to have come across the web pages and look forward to some more cool moments reading here. Thank you again for all the details.

    回复 2019年10月13日
  12. yeezy shoes

    I wish to express my appreciation for your kindness in support of folks who must have help with your situation. Your personal commitment to passing the message across had been especially insightful and has surely empowered girls like me to realize their targets. The interesting guidelines entails much to me and still more to my peers. Warm regards; from everyone of us.

    回复 2019年10月12日
  13. jordan retro

    I happen to be writing to make you understand of the incredible experience my daughter experienced visiting your web page. She realized a wide variety of issues, not to mention what it’s like to possess an amazing giving mood to have many more without hassle learn specific very confusing subject matter. You truly surpassed her expectations. I appreciate you for delivering those precious, trusted, revealing and in addition cool thoughts on that topic to Sandra.

    回复 2019年10月9日
  14. balenciaga shoes

    I wanted to write down a brief message to be able to thank you for some of the great items you are placing at this site. My long internet search has at the end been honored with reasonable ideas to go over with my colleagues. I would claim that most of us website visitors are undeniably lucky to be in a very good website with so many awesome professionals with insightful guidelines. I feel rather fortunate to have discovered your entire web pages and look forward to some more awesome moments reading here. Thank you once more for everything.

    回复 2019年10月8日