Jump to content

Setting Cookies, Setting Timestamp instead...


PC Nerd

Recommended Posts

hi guys.

 

im setting cookies for my login and instead of storing the values i want it to, its storing a timestamp instead

 

my code is in a few pages, althoug ill summerise my data, and only post the code that creates the cookies:

 

 

 

Code:

 

 

 

$User_Name = $_POST['User_Name'];

$User_ID = $Login['User_ID'];

$Login_ID = $Login['Login_ID'];

#$Logged_In = "YES";

#$Active = "Yes";

 

setcookie("User_Name", $User_Name, strtotime('+ 30 minutes'));

setcookie("Login_ID", $Login_ID, strtotime('+ 30 minutes'));

setcookie("User_ID", $User_ID, strtotime('+ 30 minutes'));

 

 

 

$Login is an array storing values retreive from the database.  when loging in.  it saves your login, time, user id to a table.  $Login_Array is simply retreiving this record again, so that the Auto_increment field "login_ID" can be stored in the cookie.  $DB_Login is a returned test to check whether or not the user_Name entered is even in the database.....  $_POST['User_Name'] is the User_Name entered by the user to login.  now my cookies are saving the following data, and theres still a "phanton" cookie that i used to use to have the expire time to check wherer or not their logged in....  The cookies are:

 

 

User_Name => 1176012801

Logged_In => 1176012801

Login_ID => 1176012801

User_ID => 1176012801

 

 

these change everytime that the user logs in....... and gets deleted when the user logs out.....

 

 

also, when i veiw the cookies on the page where they are created...... they are there, but i  know that you shouldnt be able to veiw a cookoie on the page where its created....

 

 

i would really appreciate anyoes help in this problem, its been really annoying me for a few days now.

 

thanks,

PC Nerd

 

 

PS, im reposting, becauase my other one becamase dead as it was very long.  its here

http://www.phpfreaks.com/forums/index.php/topic,135203.0.html

Link to comment
Share on other sites

could you try running this and tell me if it runs correctly? (just give a known value to the variables)


<?php

$_POST['User_Name'] = "foo";
$Login['User_ID'] = 123;
$Login['Login_ID'] = 123;

$User_Name = $_POST['User_Name'];
$User_ID = $Login['User_ID'];
$Login_ID = $Login['Login_ID'];

setcookie("User_Name", $User_Name, strtotime('+ 30 minutes'));
setcookie("Login_ID", $Login_ID, strtotime('+ 30 minutes'));
setcookie("User_ID", $User_ID, strtotime('+ 30 minutes'));

?>

 

Link to comment
Share on other sites

Just saved to a server on my localhost, ran it, worked fine.  Checked Firefox cookies to ensure the values, came up with:

User_Name: foo

User_ID: 123

Login_ID: 123

 

It appears to be an issue with your browser.  Either that or you have some content being printed to the user somehow before the setcookie command is sent.

Link to comment
Share on other sites

yeah i do, thankx

 

 

um, shouldnt it be returning a "output sent by ..........."

 

im logging the page request..... which is querying the database..........

 

if i user setcookie, then header, in another page, would that still work, becauase its all header information?

 

 

i still dont know, becauase whenever i login again, the timestamp changes to the current ( i think its the current one)

 

 

so ill try to change it, but i dont htink that itll work becauase of the timestamp.....

 

thanks though, ill give it a go

 

Link to comment
Share on other sites

ok, now its relocating but the timestamp is always the same..........

 

 

would it be better for me to post all the files as attachemnts, or post them here...... theres about 3 or 4 files that are required to login.

 

 

thanks for all you help

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.