/    Sign up×
Community /Pin to ProfileBookmark

My site is unabled to keep cookies from PC of a my friend

I’ve created a login form and other pages that keeps informations about the login.
All works fine on my pc and other my devices, but my friend with windows XP is unable to keep sessions from a page to another, either with firefox and chrome, while from his tablet all works fine
I’m assured that firefox is setted to keep cookies from alla sites, same in Control Panel -> Privacy of windows XP

I don’t know what else i can do!
My site have a tk extension, maybe it’s part of the problem?

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMar 13.2014 — Sometimes this can be caused by one user using the "www." subdomain and another not ("www.exmaple.com/index.php" versus "example.com/index.php"), while links on the page use one format or the other. Easiest way to avoid this is to specify the domain when setting the cookie to just use the domain with a leading dot, so that the cookie applies to any subdomain or no subdomain:
[code=php]
setcookie('user', $user, 0, '/', '.example.com'); //note leading "." with domain
[/code]
Copy linkTweet thisAlerts:
@American_horizoauthorMar 13.2014 — 
[code=php]
setcookie('user', $user, 0, '/', '.example.com'); //note leading "." with domain
[/code]
[/QUOTE]


and in the case of sessions, what i should write?

setcookie should be called after or before session_start() ?
Copy linkTweet thisAlerts:
@NogDogMar 13.2014 — For sessions, if possible, you want to set session.cookie_domain in your php config. If that's not possible/practical, then each place where you call session_start(), you can add it there:
[code=php]
<?php
session_set_cookie_params (0, '/', '.example.com'); // must be before session_start()
session_start();
[/code]
Copy linkTweet thisAlerts:
@American_horizoauthorMar 17.2014 — the
[code=php]setcookie('user', $user, 0, '/', '.example.com'); //note leading "." with domain [/code]
works fine on pc of my friend (the user variable is readable)

While
[code=php]session_set_cookie_params (0, '/', '.exemple.com'); //
session_start(); [/code]


continued to no work! :mad:

So, i deduce that it's not a cookie problem (else the first method would not have to work), but it's explicitly a problem with sessions
Copy linkTweet thisAlerts:
@NogDogMar 18.2014 — Just to make sure we don't miss anything obvious, I'll ask the (hopefully) silly question: you did change ".example.com" to your domain name, right? ?
Copy linkTweet thisAlerts:
@American_horizoauthorMar 18.2014 — yes! ?

If you want to try, go to gametalking.tk/login.php and insert:

Username: Tester

Password: password
×

Success!

Help @American_horizo spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...