views:

50

answers:

3

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 always shows the session id) Everything works in Mozilla and IE. Please help! Thanks

A: 

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

pleasedontbelong
Safari shows me all the cookies, I used "session_name()", it shows it too. But no changes, when I copy and paste the URL, it gives me the same session id and shows the page. When I refresh it, it disappears again.
Tamara
well then.. @Col. Shrapnel is right, you have to check if the id is the same.. and debug your code.. test with a simple page, try to find out what's wrong, if you pout your page online maybe we could test it
pleasedontbelong
A: 

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 wathch 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

Col. Shrapnel
Yes, it's the same exact id. In my safari settings in "Accept cookies" it says "always"
Tamara
@Tamara well you have to debug your code. if it's the same id, its NOT a technology issue but code issue. You have to debug it
Col. Shrapnel
A: 

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!

Tamara