Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9120643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:40:14+00:00 2026-06-17T05:40:14+00:00

I am creating cookies in a loginform.php file like this : $time = time();

  • 0

I am creating cookies in a loginform.php file like this :

$time = time();
setcookie('myusername', $myusername, $time +60*60*24*200); // Sets the cookie username
setcookie('myuserid', $rows['userid'], $time +60*60*24*200); // Sets the cookie password
setcookie('myname', $rows['name'], $time +60*60*24*200);

this file is located in a folder named login which is located in the root directory of my website.

I am able to retrieve the cookies in loginform.php but not at anyother file in the root directory ..

What may be the problem ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:40:15+00:00Added an answer on June 17, 2026 at 5:40 am

    From manual,

    The path on the server in which the cookie will be available on. If set to ‘/’, the cookie will be available within the entire domain. If set to ‘/foo/’, the cookie will only be available within the /foo/ directory and all sub-directories such as /foo/bar/ of domain. The default value is the current directory that the cookie is being set in.

    You need to set the cookie path to / to access it from anywhere. So it’ll be like,

    setcookie('myusername', $myusername, $time +60*60*24*200, '/'); 
    

    Its not a good idea to set sensitive information like username or user id in cookie. Any one can change the value and become someone else.

    Its better to use Session. Even the session id will be saved in cookie but its hard to guess another session id.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a cookie in CakePHP using setcookie() from /cake/contoller_name/method/parameter this page .
Most php / curl samples recommend creating curl cookies, and I am using one
I am creating an array to store in cookie using jquery.cookies.js Below is the
I am creating a cookie and storing the value of username after succesfull login.
I'm creating a bunch of cookies for a new website including username and password
I am creating some cookies in my ASP.NET application. These cookies expire 10 minutes
Possible Duplicate: Firefox session cookies I'm creating a website in which users are allowed
I'm testing some cookies that I'm creating via JavaScript. Is there a way to
I develop a web by using ASP.NET MVC2. Creating the cookie in the background.
I'm trying to get a certain cookie in a java client by creating a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.