开发者

php session doesn't work in safari

开发者 https://www.devze.com 2023-01-13 08:17 出处:网络
I have a simple login page. Everything works fine in Mozilla and IE. When I try to login in Safari, the session is empty, just a white page. If i check the session id, it gives me the id, but shows no

I have a simple login page. Everything works fine in Mozilla and IE. When I try to login in Safari, the session is empty, just a white page. If i check the session id, it gives me the id, but shows nothing else. echo session_id(); If I copy the page URL and then go to another page, and paste the URL, the browser shows the page.If I refresh it, it disappears again.(but it alwa开发者_StackOverflow社区ys shows the session id) Everything works in Mozilla and IE.

update: Thank you all for your help, yes, it was something on the page, I tried a simple page and it worked. Learned my lesson. Thanks again!


sessions in php use a session cookie, so check this:

  • is your safari browser allowing cookies?, by default the session cookie it's called "phpsessionid"
  • are you sure that you used a "session_start()"? (and its better if you use a "session_name()" too)

i hope this helps


Just check Safari's cookie policy.
It looks like your browser just do not send a session id cookie back.

If i check the session id, it gives me the id

It is not session id itself what ou have to check.
But rather if session id is the same as before

if it's the same, there is something with your code.
You have to start to debug it.
Start from running a test file with this code:

<?php 
session_start(); 
if (!isset($_SESSION['counter'])) $_SESSION['counter']=0;
echo "Counter ".$_SESSION['counter']++." раз.<br>
<a href=".$_SERVER['PHP_SELF'].'?'.session_name().'='.session_id().">reload</a>";

if it works, make it

<?php 
session_start(); 
if (!isset($_SESSION['counter'])) $_SESSION['counter']=0;
echo "Counter ".$_SESSION['counter']++." раз.<br>
<a href=".$_SERVER['PHP_SELF'].">reload</a>";

and find a way to watch an HTTP interchange protocol. That's most important thing - to see what cookies going from server and back. I know no tool for safari but there is ought to be one

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号