Forum Moderators: coopster

Message Too Old, No Replies

variable passing php with chrome / firefox / safari

session & cookie issues

         

jason_m

2:30 pm on Jun 17, 2010 (gmt 0)

10+ Year Member



hello,
my basic issue: i allow a user login using a form, passed to a verification page, which then registers variables and lastly allows the user to visit the posting page.

now, on this posting page i allow a content management system (edit and delete old posts).

i do so by displaying results in a div that is formatted with scroll and two links "Edit" and "Delete". if the users clicks the edit button it will reload the page with a query sent to the blog DB, pulling the info from the old post and populating my forms.

this works PERFECTLY in firefox on a PC, but not so on a mac (w firefox). this also does not work on a pc with Chrome, nor does it work w safari on a mac.

any insight would be largely appreciated.
code below:

<?
session_start();
?>

<html>
<head>
<script type="text/javascript" src="JSstuff.js"></script>

<link rel="stylesheet" type="text/css" href="styles.css" />
</head>

<?
//if user has clicked to edit, on chrome the bottom conditional comes back false.
if (isset($_SESSION['user'])){

//page content, a mySQL connection etc. this works perfect and is not the srouce of issue.

$view_db .='<a class="edit_entry" href="post.php?edit_id='.$row['id'].'">E</a>'; //this is the link they click to redirect back with a edit id defined
} //load page stuff
?>
</html>



now, if i click the edit link on firefox on a pc, works JUST as i intended. but anywhere else it shows me a blank page.

this is because the session variable of user is getting unset somehow. this may be trivial to some of you, but it is definitely stumping me.

any help would be really great.
thanks

Readie

6:09 pm on Jun 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you tried turning error reporting and show errors on and seeing if you get any messages?

rocknbil

6:33 pm on Jun 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Add this.

if (isset($_SESSION['user'])){
// your code
} //load page stuff
else {
echo "<p>No session was found.</p>";
}


Though I can't say **why**, it may very well be your Mac is not accepting cookies, or is munging them, or is sending a broken cookie back to the server (go figger . . . .) PHP sessions rely on a PHPSESSID cookie being set.

Manual [us.php.net]

session_start() creates a session or resumes the current one based on a session identifier passed via a GET or POST request, or passed via a cookie.

jason_m

6:41 pm on Jun 17, 2010 (gmt 0)

10+ Year Member



thank you for your input.
i think i have decided to just store session id in a table with a timer. i know this is basically a cookie, but so be it. it seems relatively flawless (not relying on cookies being turned on locally, and also not relying on these session variables which seem relatively buggy as it is) also keeps from obfuscating or making url bar look gnarly.

thank you for input

Matthew1980

6:47 pm on Jun 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there jason_m,

May be worth doing the full php tags too (<?php) - this will make for better compatibility if you come to change servers one day as not all servers support short tags in the ini file. Just thought i should mention that.

Cheers
MRb

rocknbil

4:29 am on Jun 18, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



i know this is basically a cookie,

Well I could be wrong, and it could be something else . . . . . did you add that little else snippet to see if it's setting the session OK?

jason_m

8:02 pm on Jun 23, 2010 (gmt 0)

10+ Year Member



hi everyone,

my site works the following way:
login form -> check login credentials
if they pass -> redirect to CMS page to post new, edit or delete old posts
if they don't pass - > go away.

issue:
user clicks link to be redirected to edit page (which is really just establishing and passing a new session variable.

oh chrome/safari & mac firefox the session somehow comes unset.

all variables are unset once the user clicks the edit button.

Matthew1980

8:11 pm on Jun 23, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there Jason_m,

Is this a live site, or is it localhost on your pc/laptop/mac?

This sounds like something in the ini file, though I could be wrong, I just have a feeling on that ;)

How are you passing/setting the $_SESSION from page to page?, because once it's set it should stay set until either the browser is shut or, the $_SESSION is terminated.. Other than that it's something in the ini file.

There was a similar thread earlier this year on this matter infact: [webmasterworld.com ] that could shed some light on where to look...

Cheers,
MRb