切换城市功能怎么设计
请问大家你们是怎么设计切换城市的,我百度一下,也没找到方法
我的想法是(当然还没有写程序,目前正在看七牛云的上传图片的功能)
1,进入网站,用iP 定位当前城市,并把城市的id记录在session中
2,如果更改城市(定位错误,或用户自己更改),用户手动更改,然后更改session的城市id
大家有什么建议,给说一下,或者你们是怎么样做的。
回复内容:
请问大家你们是怎么设计切换城市的,我百度一下,也没找到方法
我的想法是(当然还没有写程序,目前正在看七牛云的上传图片的功能)
1,进入网站,用iP 定位当前城市,并把城市的id记录在session中
2,如果更改城市(定位错误,或用户自己更改),用户手动更改,然后更改session的城市id
大家有什么建议,给说一下,或者你们是怎么样做的。
ip 或者gps 定位(如果是购物站,可以根据收货地址记录)。
一般来说存在cookie 足够,但是根据ip 判断一下更好,除非是长城宽带、铁通 这样全国票的isp ,否则还是很准确的,对于经常移民的蚁族,还是不错的。
存cookie里就行 可以参考京东
App: 百度地图API或者Apple地图API都有反向地址接口,可以捕获到GPS对应城市
Web:百度好像也有类似接口;此外,在项目中也用过geoip-lite,也还行。
Web开发的话,新浪、搜狐有根据用户IP判断位置的API。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.
