请问 我的页面上的session_id 为什么在不停的变化 不是固定的 我每刷新一次它就变化一次 这个应该是固定的啊
是什么问题导致的啊
回复讨论(解决方案) 浏览器不支持cookie?
多半是 session.auto_start = 1
也不排除你的浏览器不支持 cookie
session.auto_start = 0
我的浏览器支持cookie
那只能贴代码说话啦
rss.php
先访问上面的文件 然后访问下面的文件 两次的session_id 不一样
index.php
rss.php加url跳转过去
不要新开浏览器窗口
一样的效果
在每段代码的后面加上
print_r($_cookie);
在每段代码的后面加上
print_r($_cookie);
我打印了都是空数组
那就是 cookie 不支持了,无论如何 $_cookie['phpsessid'] 都应该有的
你更改了 php.ini 中 session 相关的设置了吗?
我没有改 php.ini 现在要怎么办
现在要怎么解决问题我也郁闷了 怎么没有 phpsession 这个cookie
我的浏览器是支持cookie的 这个不用怀疑
弱弱的问一下,session_id 对程序而言有什么特殊用途吗?通常是操作$_session就可以了吧
你用 setcookie 设一个 cookie 变量再试试是否能读回来
同样的代码 放在别人的电脑上面都可以的 我的是怎么回事啊
echo ini_get(session.use_cookies);//这个值多少
你用 setcookie 设一个 cookie 变量再试试是否能读回来
这个可以 我试过了 没有问题
注意开启错误提示看有无错误信息
error_reporting(e_all);ini_set('display_errors',true);
然后session相关的php.ini配置信息贴出来,大家好帮你分析。
[session]
; handler used to store/retrieve data.
; http://php.net/session.save-handler
session.save_handler = files
; argument passed to save_handler. in the case of files, this is the path
; where data files are stored. note: windows users have to change this
; variable in order to use php's session functions.
;
; the path can be defined as:
;
; session.save_path = n;/path
;
; where n is an integer. instead of storing all the session files in
; /path, what this will do is use subdirectories n-levels deep, and
; store the session data in those directories. this is useful if you
; or your os have problems with lots of files in one directory, and is
; a more efficient layout for servers that handle lots of sessions.
;
; note 1: php will not create this directory structure automatically.
; you can use the script in the ext/session dir for that purpose.
; note 2: see the section on garbage collection below if you choose to
; use subdirectories for session storage
;
; the file storage module creates files using mode 600 by default.
; you can change that by using
;
; session.save_path = n;mode;/path
;
; where mode is the octal representation of the mode. note that this
; does not overwrite the process's umask.
; http://php.net/session.save-path
session.save_path = d:/wamp/tmp
; whether to use cookies.
; http://php.net/session.use-cookies
session.use_cookies = 1
; http://php.net/session.cookie-secure
;session.cookie_secure =
; this option forces php to fetch and use a cookie for storing and maintaining
; the session id. we encourage this operation as it's very helpful in combatting
; session hijacking when not specifying and managing your own session id. it is
; not the end all be all of session hijacking defense, but it's a good start.
; http://php.net/session.use-only-cookies
session.use_only_cookies = 1
; name of the session (used as cookie name).
; http://php.net/session.name
session.name = phpsessid
; initialize session on request startup.
; http://php.net/session.auto-start
session.auto_start = 0
; lifetime in seconds of cookie or, if 0, until browser is restarted.
; http://php.net/session.cookie-lifetime
session.cookie_lifetime = 1000
; the path for which the cookie is valid.
; http://php.net/session.cookie-path
session.cookie_path = /
; the domain for which the cookie is valid.
; http://php.net/session.cookie-domain
session.cookie_domain =80tao.dev
; whether or not to add the httponly flag to the cookie, which makes it inaccessible to browser scripting languages such as javascript.
; http://php.net/session.cookie-httponly
session.cookie_httponly =
; handler used to serialize data. php is the standard serializer of php.
; http://php.net/session.serialize-handler
session.serialize_handler = php
; defines the probability that the 'garbage collection' process is started
; on every session initialization. the probability is calculated by using
; gc_probability/gc_divisor. where session.gc_probability is the numerator
; and gc_divisor is the denominator in the equation. setting this value to 1
; when the session.gc_divisor value is 100 will give you approximately a 1% chance
; the gc will run on any give request.
; default value: 1
; development value: 1
; production value: 1
; http://php.net/session.gc-probability
session.gc_probability = 1
; defines the probability that the 'garbage collection' process is started on every
; session initialization. the probability is calculated by using the following equation:
; gc_probability/gc_divisor. where session.gc_probability is the numerator and
; session.gc_divisor is the denominator in the equation. setting this value to 1
; when the session.gc_divisor value is 100 will give you approximately a 1% chance
; the gc will run on any give request. increasing this value to 1000 will give you
; a 0.1% chance the gc will run on any give request. for high volume production servers,
; this is a more efficient approach.
; default value: 100
; development value: 1000
; production value: 1000
; http://php.net/session.gc-divisor
session.gc_divisor = 1000
; after this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
; http://php.net/session.gc-maxlifetime
session.gc_maxlifetime = 1440
; note: if you are using the subdirectory option for storing session files
; (see session.save_path above), then garbage collection does *not*
; happen automatically. you will need to do your own garbage
; collection through a shell script, cron entry, or some other method.
; for example, the following script would is the equivalent of
; setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
; cd /path/to/sessions; find -cmin +24 | xargs rm
; php 4.2 and less have an undocumented feature/bug that allows you to
; to initialize a session variable in the global scope, even when register_globals
; is disabled. php 4.3 and later will warn you, if this feature is used.
; you can disable the feature and the warning separately. at this time,
; the warning is only displayed, if bug_compat_42 is enabled. this feature
; introduces some serious security problems if not handled correctly. it's
; recommended that you do not use this feature on production servers. but you
; should enable this on development servers and enable the warning as well. if you
; do not enable the feature on development servers, you won't be warned when it's
; used and debugging errors caused by this can be difficult to track down.
; default value: on
; development value: on
; production value: off
; http://php.net/session.bug-compat-42
session.bug_compat_42 = on
; this setting controls whether or not you are warned by php when initializing a
; session value into the global space. session.bug_compat_42 must be enabled before
; these warnings can be issued by php. see the directive above for more information.
; default value: on
; development value: on
; production value: off
; http://php.net/session.bug-compat-warn
session.bug_compat_warn = on
; check http referer to invalidate externally stored urls containing ids.
; http_referer has to contain this substring for the session to be
; considered as valid.
; http://php.net/session.referer-check
session.referer_check =
; how many bytes to read from the file.
; http://php.net/session.entropy-length
session.entropy_length = 0
; specified here to create the session id.
; http://php.net/session.entropy-file
;session.entropy_file = /dev/urandom
session.entropy_file =
; http://php.net/session.entropy-length
;session.entropy_length = 16
; set to {nocache,private,public,} to determine http caching aspects
; or leave this empty to avoid sending anti-caching headers.
; http://php.net/session.cache-limiter
session.cache_limiter = nocache
; document expires after n minutes.
; http://php.net/session.cache-expire
session.cache_expire = 180
; trans sid support is disabled by default.
; use of trans sid may risk your users security.
; use this option with caution.
; - user may send url contains active session id
; to other person via. email/irc/etc.
; - url that contains active session id may be stored
; in publically accessible computer.
; - user may access your site with the same session id
; always using url stored in browser's history or bookmarks.
; http://php.net/session.use-trans-sid
session.use_trans_sid = 0
; select a hash function for use in generating session ids.
; possible values
; 0 (md5 128 bits)
; 1 (sha-1 160 bits)
; http://php.net/session.hash-function
session.hash_function = 0
; define how many bits are stored in each character when converting
; the binary hash data to something readable.
; possible values:
; 4 (4 bits: 0-9, a-f)
; 5 (5 bits: 0-9, a-v)
; 6 (6 bits: 0-9, a-z, a-z, -, ,)
; default value: 4
; development value: 5
; production value: 5
; http://php.net/session.hash-bits-per-character
session.hash_bits_per_character = 5
; the url rewriter will look for urls in a defined set of html tags.
; form/fieldset are special; if you include them here, the rewriter will
; add a hidden field with the info which is otherwise appended
; to urls. if you want xhtml conformity, remove the form entry.
; note that all valid entries require a =, even if no value follows.
; default value: a=href,area=href,frame=src,form=,fieldset=
; development value: a=href,area=href,frame=src,input=src,form=fakeentry
; production value: a=href,area=href,frame=src,input=src,form=fakeentry
; http://php.net/url-rewriter.tags
url_rewriter.tags = a=href,area=href,frame=src,input=src,form=fakeentry
session.cookie_domain =80tao.dev
这个值去掉吧,,你确认需要?
这个是我项目的一个 配置 有影响吗
你说的去掉指的是什么意思
session.cookie_domain =80tao.dev
把这个去掉就可以了
但是为什么啊
session.cookie_domain =80tao.dev
把这个去掉就可以了
但是为什么啊
看命名还不清楚啊,,限制域啦
那个是设置session对应的cookie在什么域有效的
你是本地测试么?是http://localhost这么去访问你的项目的么?是的话就去掉,如果是正式站点,你改成
#注意加的那个点,表明所有子域有效,包括wwwsession.cookie_domain = .80tao.dev
试下。
我填写那个域为什么就不行了啊 默认是空的 为什么 给我解释一下吧
那个是设置session对应的cookie在什么域有效的
你是本地测试么?是http://localhost这么去访问你的项目的么?是的话就去掉,如果是正式站点,你改成
php code
#注意加的那个点,表明所有子域有效,包括www
session.cookie_domain = .80tao.dev
试下。
这个很奇怪啊,我好像没见过.dev的正式域名,有吗?
session.cookie_domain =80tao.dev
表示 session 只在 80tao.dev 域有效
所以需要也在这个域中测试你的代码
引用 24 楼 的回复:
session.cookie_domain =80tao.dev
把这个去掉就可以了
但是为什么啊
看命名还不清楚啊,,限制域啦
我是本地反问
我填写那个域为什么就不行了啊 默认是空的 为什么 给我解释一下吧
是我本地的虚拟主机 配置的虚拟域名
引用 26 楼 的回复:
那个是设置session对应的cookie在什么域有效的
你是本地测试么?是http://localhost这么去访问你的项目的么?是的话就去掉,如果是正式站点,你改成
php code
#注意加的那个点,表明所有子域有效,包括www
session.cookie_domain = .80tao.dev
试下。
这个很奇怪啊,我好像没……
怎么一说还真是,有点奇葩了,我也没见过dev的域名。
这个很奇怪啊,我好像没见过.dev的正式域名,有吗?
是我本地的虚拟主机 配置的虚拟域名
好吧 表示我不知道
知道这个是个老帖了,可是我最近也遇到这个问题了。也是session_id不段变化,无法做购物车。然后我人为地用session_id(某个值'),可是竟然session不会过期了,无论怎样关浏览器,上一个会话还是存在。希望有大神在这里给我解答一下。谢谢了