//STUFF FROM HERE TO THE OTHER COMMENT IS STUFF I ADDED MANUALLY TRYING TO GET THE COOKIES TO BE SET SO THEY WORK FOR BOTH $username = $_COOKIE['user_id']; $pass = $_COOKIE['pass_id']; setcookie("user_id", "$username", time()+3600); setcookie("pass_id", "$pass", time()+3600); //END OF THE CUSTOM STUFF, IT DOESNT WORK FOR SOME REASON

//and then move them to the index page or the page to which they need to go header('Location: index.php'); }else{ $err = 'Incorrect username / password.' ; } //then just above your login form or where ever you want the error to be displayed you just put in echo $err; } else

?>

I made comments // in the code so you can see whats going on.

Here is the code that uses cookies, also it uses 2 pages.This is the one I think that mainly adds the cookies.<?php// Login Logic

//STUFF FROM HERE TO THE OTHER COMMENT IS STUFF I ADDED MANUALLY TRYING TO GET THE COOKIES TO BE SET SO THEY WORK FOR BOTH $username = $_COOKIE['user_id']; $pass = $_COOKIE['pass_id']; setcookie("user_id", "$username", time()+3600); setcookie("pass_id", "$pass", time()+3600); //END OF THE CUSTOM STUFF, IT DOESNT WORK FOR SOME REASON

//and then move them to the index page or the page to which they need to go header('Location: index.php'); }else{ $err = 'Incorrect username / password.' ; } //then just above your login form or where ever you want the error to be displayed you just put in echo $err; } else

?>

I made comments // in the code so you can see whats going on.

Here is the code that uses cookies, also it uses 2 pages.This is the one I think that mainly adds the cookies.<?php// Login Logic

Logins With Remember Me - Sessions, Cookies Or Both

I am about to attempt to write my first php script from scratch after a year or so of copying and adapting code.

I am going to do a registration/login in system and thinking ahead, want to make sure that once someone is logged in, this information is passed from page to page (so they do not have to log in again on each page) and I would also like to provide a 'Remember Me' option.

I have had a read up and from what I gather, sessions would be better for showing someone is logged in from page to page and cookies would be the only way to implement a 'Remember Me'.

Would this be the best way to approach this or is/are there better ways?

Cookies And Sessions

Hello , my website uses sessions to check for users if they are logged in, get data and such stuff..

But i want to add cookies in order to make users stay logged in for more time..

I do have a remember me checkbox and a function that tells me if a user is loggedin by checking if session or cookie is set and then it returns a true flag... the problem is that i dont know how to get if he is logged via session or cookies

Sessions And Cookies

I have attached a very simple remember me script. Could someone please have a look at it and tell me if I'm doing it correctly, or what the correct implementation would be to allow users to not use and use the remember me function?

Sessions And Cookies

I am having a hard time getting sessions and cookies to work as I would expect. I am using codelobster editor/debugger and wampserver. My problem is that when I try to delete a cookie it shows that the cookie is still there and active.

<?PHPsession_start();date_default_timezone_set('Asia/Qatar');// I try to delete the previous cookie which was setsetcookie('my_session',"",time()-3600);// here I have a function that sets a cookielog_session("username","password");session_destroy();?>

When I check the local variables in the debugger they are still there and not deleted and have the same value.Is my logic wrong or is it my system?

Sessions And Cookies

I want to end a session when a registered user is asked to login again but enters the incorrect credentials. I'm destroying the session and taking the user back to the login page, but for some reason when s/he clicks "back" on the browser s/he is able to get back into her/his account. Any ideas?

Bit Of A Dilemma, Need Help With Cookies And Sessions

I need advice on how to handle a php issue. I will try to simply my problem as best as I can.

Index.php is used to upload multiple picturesengine.php is called each time for each picture. So if someone uploads 3 pictures engine.php is called 3 times and uploads each picture separately.

What I want to be able to do is to track bulk uploads. For example, if someone uploads 10 pictures at once there would be a unique code in my database that I could query and see the results of the 10 pictures that where uploaded. Kinda like a batch. The problem is that I can't seem to create a unique code that it's used to to track batches.

I have used cookies in my index.php and set it to a random variable. When my engine.php starts uploading images via POST method, it calls the cookie that was stores in index.php only to see that the value doesn't get passed. I check index.php by using echo $_COOKIE['...']; and a value does get into the cookie, but engine.php can't seem to access the cookie. (I used setcookie)Here's part of the code for the cookies (engine.php):

if I set $getmu to just any string, it seems to get inserted into the db, so it's not a syntax issue. When I use cookies, nothing gets inputed.

I also tried using sessions, but since engine.php is called for each picture upload, the session changes for every picture. Any ideas or advice? I'm kinda stuck on this. The cookies should work, but they don't :/

Question Regarding Sessions And Cookies

On my site I offer the option an option for cookies or sessions on login. If a remember me box is selected, then a cookie will be set. My question is, how do I assign both the $_SESSION['id'] and $_COOKIE['id'] to the same variable?

Thanks for the help!

Sessions Cookies Error Message

Hello again, I posted a question earlier about an include issue which I managed to fix but now I am dealing with a completely new error message and unlike before I don't even have a basic Idea of what is going on.

// Only print an error message if the error isn't a notice: if ($e_number != E_NOTICE) { echo '<div class="error">A system error occurred. We apologize for the inconvenience.</div><br />'; } } // End of !LIVE IF.

At first I thought it was because cookies weren't enabled but I am positive they are, so I am really at a loss as-to what's going on, there is more to the error message, though its quite long and will take me a few minutes to go through and remove/alter any sensitive information.

How, If Possible, Could I Implement Cookies And Sessions Into A Code Like This?

Code: [Select]<!----In this block of code, I am creating a PHP script that gets the user inputted values and can display them in a report as well as use an IF statement to show an extra line to appear if the user enters an age below 18 or a time since accident below 1 week or if they miss out a field or more----><?php

if (empty($_POST['firstname']) or empty($_POST['surname']) or empty($_POST['age']) or empty($_POST['weeks'])){$msg= "You missed out one or more fields. Click on the link below to go back to the form and enter information into all of the fields";}else if (is_numeric($age) && $age<0){$msg="You cannot be under 0 years of age";}else if (is_numeric($weeks) && $weeks<0){$msg="The number of weeks since an accident cannot be below 0";}else if (is_numeric($age) && $age>0 && $age<18){$msg= "You are too young to file an accident report";}

else if (is_numeric($weeks) && $weeks<2){$msg= "You cannot file an accident report that happened less than two weeks ago";}else{setcookie("$msg= "First Name: $firstname<br>";$msg .="Surname: $surname<br>";$msg .= "Age: $age<br>";$msg .="Number of weeks since accident: $weeks<br>";$msg .="Your report has been accepted. Please click on the link below to go back to the Accident Report Page";}echo ($msg)?>

</body></html><html><a href="http://localhost/Car.htm"><br><br>Click here to add/edit an Accident Report</a>I was wondering how, if suitable, I would add a cookie or session into coding like this.

Having Problem While Storing Data In Sessions & Cookies

I have created a login form. I am sending values through Ajax for form validation. However, I am having problem with the code that I am unable to store values in Sessions & Cookies.
I have added a "Remember me" checkbox into login form. I want to validate Boolean value using Javascript Checked property and send the data to PHP for validation.
If user clicks on remember me checkbox then the data should be stored in either Sessions & Cookies. If it is not checked then data should be stored only in Sessions. I am posting here my login form code, Ajax code & PHP code.
Could you guys help me to point out my mistake what I am doing wrong in this code?
Login Form:

Sessions And Cookies - Logged In Until Users Sign Out.

What I am trying to achieve is once a user has logged in depending on wether they have checked the keep me logged in checkbox they have two options. If they haven't checked it then it creates session variables only, and if they have checked it it also creates cookie variable as well as the session variables.

If they then close their browser / tab without logging out and then revisit the site they will get redirected to login page because the active session variable is no longer there. As soon as they land on the loggin page, it automatically checks for the cookie variable and if it exists, it uses it to login and redirect them automatically.

However the problem that I am facing is that the session variable is still being trashed after a default amount of idle time and forcing a login.

My goal is that the user shouldn't have to re-login unless they have either clicked the logout button.

Can someone please have a look through my solution and advise me as to wether this is the correct method that I am implementing, if there is an easier way to achieve what I want, and is this a secure way to handle user logins.

Advanced Cookies && Sessions && Mysql For User And Profile Management

I am exploring the delightful world of PHP for web applications. I am in the stage where I need to use SESSIONS and COOKIES and MYSQL for a user/membership/profile structure. I understand most of the grammar behind PHP and am excited to apply this in application.
I am searching for recommendations and comments about using:

1. COOKIES
2. SESSIONS
3. MYSQL/SQL
Almost every website has an authentication mechanism, profile, and use information. My website required this similar structure, but I have been having some problems completing all of the technical steps for production.
If anyone has code samples or places where I can review code on this topic, that would be wonderful. I am specifically searching for more advanced topics in these area for general robustness.
Please kindly send me a message or respond to this post.

Logs

I have a mysql table in which will be updated fairly frequently via php code on a form.My question is how do I code a log of the changes made into another table using php or calling a stored procedure from within the database. or if you can think of a better way suggest it. Stored procedure would be more secure if possible.