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

  • SEARCH
  • Home
  • 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 6474543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:35:57+00:00 2026-05-25T06:35:57+00:00

So i have a page where i have stored the users username as a

  • 0

So i have a page where i have stored the users username as a cookie and use it for different things. However i have hit a wall. If the username contains anything that is / when using escape_string things act up. I was able to get the username to be echo‘ed correctly on one page however on another page i am not able to get it to come up properly. If i just echo the cookie on that page straight up i get / (the username im using is “” just to test). My server seems to auto escape variables sometimes so i am not 100% sure when it auto applies slashes and when it doesn’t, as when i send out variables using php (sending out email with variable) they are escaped and when i save them to the database (sending variable to mysql) they are not slashed? So here is my code for everything i think might help, keep in mind the username in this case is “”.

Registering the username:

 $username = mysql_real_escape_string($_POST['username']);

Setting up the cookie:

$username = mysql_real_escape_string($_GET['username']);
$user = stripslashes($username);
setcookie('username', $user, time()+3600*24);

Working page:

  if(isset($_COOKIE['username']))
   { 
  $login = '<a id="popup_link_3" class="popup_link menu"><span>' . stripslashes($_COOKIE['username']) . '</span></a>'; }
else{ 
 $login = '<a  id="popup_link_2" class="popup_link menu"><span>Login</span></a>';
 } 

here is where the username is echoed on the working page and i see “”:

 <? echo $content1 ?>
 <li> <? echo $login ?></li>
 <? echo $content2 ?>

Non working page:

 $username = $_COOKIE["username"];

what i see when i echo $username is / and when i stripslashes i see nothing.

cookie value when viewed through firefox after being set:%22%22

  • 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-05-25T06:35:57+00:00Added an answer on May 25, 2026 at 6:35 am

    Why are you using mysql_real_escape_string() for this? The function is intended to make a string safe to insert into a MySQL database query string. it is not, and never has been, intended to be used for usage in a cookie. As long as you’re using setcookie(), PHP will take care of escaping any data going into the cookie.

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

Sidebar

Related Questions

I have a page with a textbox that passed a value through a stored
I have a web page that displays a list of documents stored on the
I try to access session variables stored on a different page. When I have
I have page where I load different videos.I use jw player as player if
I have page where I use model which can have different types (depending by
Okay, my dilemma is this. I have an admin page that I use to
I have an online store. A products page that allows the user to view
I have stored page contents (tables, plain text, images and paragraphs) into a variable.
I have a session that I gave to users that has matching password =
I have a standard HTML login page, which I would much rather use than

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.